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

The following examples show how to use org.locationtech.jts.geom.Point#getCoordinate() . 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: SeaRouting.java    From searoute with European Union Public License 1.2 5 votes vote down vote up
/**
 * Get the (lon,lat) position of a network node.
 * 
 * @param n
 * @return
 */
private Coordinate getPosition(Node n){
	if(n==null) return null;
	Point pt = (Point)n.getObject();
	if(pt==null) return null;
	return pt.getCoordinate();
}
 
Example 2
Source File: GeometryHullToolTest.java    From geowave with Apache License 2.0 5 votes vote down vote up
private Geometry getHull(
    final LineString str,
    final String name,
    final boolean save,
    final boolean parkandOh) {

  final List<Point> points = CurvedDensityDataGeneratorTool.generatePoints(str, 0.4, 1000);

  final GeometryHullTool cg = new GeometryHullTool();
  cg.setDistanceFnForCoordinate(new CoordinateCircleDistanceFn());

  final Coordinate[] coordinates = new Coordinate[points.size()];
  int i = 0;
  for (final Point point : points) {
    coordinates[i++] = point.getCoordinate();
  }

  final ConvexHull convexHull = new ConvexHull(coordinates, factory);

  final Geometry concaveHull =
      parkandOh
          ? cg.concaveHullParkOhMethod(convexHull.getConvexHull(), Arrays.asList(coordinates))
          : cg.concaveHull(convexHull.getConvexHull(), Arrays.asList(coordinates));
  if (save || !concaveHull.isSimple()) {
    writeToShapeFile("setx_" + name, points.toArray(new Geometry[points.size()]));
    writeToShapeFile("chullx_" + name, concaveHull);
    writeToShapeFile("hullx_" + name, convexHull.getConvexHull());
  }

  // final Geometry concaveHull1 = cg.concaveHull1(
  // convexHull.getConvexHull(),
  // Arrays.asList(coordinates));
  // if (save || !concaveHull1.isSimple()) {
  // writeToShapeFile(
  // "chull_" + name,
  // concaveHull1);
  // }

  return concaveHull;
}