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

The following examples show how to use org.locationtech.jts.geom.Point#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: SimpleFeatureCentroidExtractor.java    From geowave with Apache License 2.0 5 votes vote down vote up
@Override
public Point getCentroid(final SimpleFeature anObject) {
  final FeatureGeometryHandler handler =
      new FeatureGeometryHandler(anObject.getDefaultGeometryProperty().getDescriptor());
  final Geometry geometry = handler.toIndexValue(anObject).getGeometry();
  final int srid = SimpleFeatureGeometryExtractor.getSRID(anObject);
  final Point point = geometry.getCentroid();
  point.setSRID(srid);
  return point;
}
 
Example 3
Source File: SimpleFeatureInteriorPointExtractor.java    From geowave with Apache License 2.0 5 votes vote down vote up
@Override
public Point getCentroid(final SimpleFeature anObject) {
  final FeatureGeometryHandler handler =
      new FeatureGeometryHandler(anObject.getDefaultGeometryProperty().getDescriptor());
  final Geometry geometry = handler.toIndexValue(anObject).getGeometry();
  final int srid = SimpleFeatureGeometryExtractor.getSRID(anObject);
  final Point point = geometry.getInteriorPoint();
  point.setSRID(srid);
  return point;
}
 
Example 4
Source File: GeoJSONTest.java    From arctic-sea with Apache License 2.0 4 votes vote down vote up
private Point randomPoint(int srid) {
    Point geometry = geometryFactory.createPoint(randomCoordinate());
    geometry.setSRID(srid);
    return geometry;
}