Java Code Examples for org.locationtech.jts.geom.LineString#setSRID()

The following examples show how to use org.locationtech.jts.geom.LineString#setSRID() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TrajectoryObservation.java    From arctic-sea with Apache License 2.0 5 votes vote down vote up
/**
 * Create geometry for featureOfInterest from
 * {@link TimeLocationValueTriple}s
 *
 * @param values
 *            The {@link TimeLocationValueTriple}s to check for
 *            featureOfInterest
 */
private void checkForFeature(List<TimeLocationValueTriple> values) {
    AbstractFeature featureOfInterest = getObservationConstellation().getFeatureOfInterest();
    if (featureOfInterest instanceof AbstractSamplingFeature) {
        AbstractSamplingFeature sf = (AbstractSamplingFeature) featureOfInterest;
        Coordinate[] coords = getCoordinates(values);
        int srid = 0;
        if (sf.isSetGeometry()) {
            srid = sf.getGeometry().getSRID();
            coords = (Coordinate[]) ArrayUtils.addAll(sf.getGeometry().getCoordinates(), coords);
        } else {
            TimeLocationValueTriple next = values.iterator().next();
            if (next.isSetLocation()) {
                srid = next.getLocation().getSRID();
            }
        }
        try {
            if (coords.length == 1) {
                Point point = new GeometryFactory().createPoint(coords[0]);
                point.setSRID(srid);
                sf.setGeometry(point);
            } else if (coords.length > 1) {
                LineString lineString = new GeometryFactory().createLineString(coords);
                lineString.setSRID(srid);
                sf.setGeometry(lineString);
            }
        } catch (InvalidSridException e) {
            // TODO
        }
    }
}
 
Example 2
Source File: ProfileObservation.java    From arctic-sea with Apache License 2.0 5 votes vote down vote up
private void setFeatureGeometry(List<Coordinate> coordinates, int srid) {
    AbstractFeature featureOfInterest = getObservationConstellation().getFeatureOfInterest();
    if (featureOfInterest instanceof AbstractSamplingFeature) {
        AbstractSamplingFeature sf = (AbstractSamplingFeature) featureOfInterest;
        Coordinate[] coords = coordinates.toArray(new Coordinate[0]);
        try {
            LineString lineString = new GeometryFactory().createLineString(coords);
            lineString.setSRID(srid);
            sf.setGeometry(lineString);
            sf.setFeatureType(SfConstants.SAMPLING_FEAT_TYPE_SF_SAMPLING_CURVE);
        } catch (InvalidSridException e) {
            // TODO
        }
    }
}
 
Example 3
Source File: GeoJSONTest.java    From arctic-sea with Apache License 2.0 4 votes vote down vote up
private LineString randomLineString(int srid) {
    LineString geometry = geometryFactory
            .createLineString(new Coordinate[] { randomCoordinate(), randomCoordinate(), randomCoordinate() });
    geometry.setSRID(srid);
    return geometry;
}