public static GHPoint create(Point point) { return new GHPoint(point.getY(), point.getX()); }
pl = instructions.get(instructions.size() - 2).getPoints(); pl.add(ptLeg.stops.get(0).geometry.getY(), ptLeg.stops.get(0).geometry.getX()); for (Trip.Stop stop : ptLeg.stops.subList(0, ptLeg.stops.size() - 1)) { pl.add(stop.geometry.getY(), stop.geometry.getX()); arrivalPointList.add(arrivalStop.geometry.getY(), arrivalStop.geometry.getX()); Instruction arrivalInstruction = new Instruction(Instruction.PT_END_TRIP, arrivalStop.stop_name, InstructionAnnotation.EMPTY, arrivalPointList); if (ptLeg.isInSameVehicleAsPrevious) {
public static double getY(Geometry arg0) { if (!(arg0 instanceof Point)) return 0d; Point _this = (Point) arg0; return _this.getY(); }
public double getY() { return point.getY(); }
@Override public double getY() { return isEmpty() ? Double.NaN : pointGeom.getY(); }
/** @see java.awt.geom.PathIterator#currentSegment(double[]) */ public int currentSegment(double[] coords) { if (!done && !moved) { coords[0] = point.getX(); coords[1] = point.getY(); at.transform(coords, 0, coords, 0, 1); return SEG_MOVETO; } else { coords[0] = point.getX(); coords[1] = point.getY(); at.transform(coords, 0, coords, 0, 1); moved = true; return SEG_LINETO; } } }
@DescribeProcess( title = "Get Y Ordinate", description = "Returns the Y value (second ordinate) for point geometries. For other geometry types returns the Y value of the centroid." ) @DescribeResult(description = "Y value of point") public static double getY( @DescribeParameter(name = "geom", description = "Input point") Point point) { return point.getY(); }
private static Cell getCentroidCell(MultiPolygon poly) { Point p = poly.getCentroid(); return new Cell(p.getX(), p.getY(), 0, poly); } }
public GeographicGenerator( Point center, int quadrantSegments, CoordinateReferenceSystem crs) { this.quadrantSegments = quadrantSegments; this.center = center; this.calculator = new GeodeticCalculator(crs); latLon = isLatLonOrder(crs.getCoordinateSystem()); if (latLon) { calculator.setStartingGeographicPoint(center.getY(), center.getX()); } else { calculator.setStartingGeographicPoint(center.getX(), center.getY()); } }
LabelPainter painter) { tempTransform.translate(centroid.getX(), centroid.getY());
private static Geometry pointInGeometry(Geometry g) { Point p = g.getCentroid(); if (g instanceof Polygon) { // if the geometry is heavily generalized centroid computation may fail and return NaN if (Double.isNaN(p.getX()) || Double.isNaN(p.getY())) return g.getFactory().createPoint(g.getCoordinate()); // otherwise let's check if the point is inside. Again, this check and // "getInteriorPoint" // will work only if the geometry is valid if (g.isValid() && !g.contains(p)) { try { p = g.getInteriorPoint(); } catch (Exception e) { // generalized geometries might make interior point go bye bye return p; } } else { return p; } } return p; }
/** * This method adds the GridConvergence Angle attribute to the Point feature if it is * needed. * * @param point Input Point to handle. */ private void gridConvergenceAngleManagement(Point point) throws Exception { // If the GridConvergence Angle correction is not requested, then nothing is done if (fc.gridConvergenceAngleCorrectionNeeded) { // // Calculate convergence angle // sourceCRSPosition.setLocation(point.getX(), point.getY()); fc.reprojectionTransformation.transform(sourceCRSPosition, targetCRSPosition); // Calculation of the Angle double convAngle = fc.gridConvergenceAngleManager.getConvergenceAngle(targetCRSPosition); fb.add(convAngle); } }
if (point.getY() >= 0) { fb.add("N"); } else {
@Test public void testToGeographicGeometry() throws Exception { // This time we are in north / east order CoordinateReferenceSystem gda94 = CRS.decode("EPSG:4939", true); GeometryFactory gf = new GeometryFactory(); Point point = gf.createPoint( new Coordinate(130.882672103999, -16.4463909341494, 97.009018073082)); Point world = (Point) JTS.toGeographic(point, gda94); assertEquals(point.getX(), world.getX(), 0.00000005); assertEquals(point.getY(), world.getY(), 0.00000005); }
/** * Reads WKT from the {@code str} via JTS's {@link org.locationtech.jts.io.WKTReader}. * @param str * @param reader <pre>new WKTReader(ctx.getGeometryFactory()))</pre> * @return Non-Null */ protected Shape parseIfSupported(String str, WKTReader reader) throws ParseException { try { Geometry geom = reader.read(str); //Normalizes & verifies coordinates checkCoordinates(geom); if (geom instanceof org.locationtech.jts.geom.Point) { org.locationtech.jts.geom.Point ptGeom = (org.locationtech.jts.geom.Point) geom; if (getShapeFactory().useJtsPoint()) return new JtsPoint(ptGeom, (JtsSpatialContext) ctx); else return getShapeFactory().pointXY(ptGeom.getX(), ptGeom.getY()); } else if (geom.isRectangle()) { return getShapeFactory().makeRectFromRectangularPoly(geom); } else { return getShapeFactory().makeShapeFromGeometry(geom); } } catch (InvalidShapeException e) { throw e; } catch (Exception e) { throw new InvalidShapeException("error reading WKT: "+e.toString(), e); } }
@Test public void testToGeographicGeometry() throws Exception { // This time we are in north / east order String wkt = "GEOGCS[\"GDA94\"," + " DATUM[\"Geocentric Datum of Australia 1994\"," + " SPHEROID[\"GRS 1980\", 6378137.0, 298.257222101, AUTHORITY[\"EPSG\",\"7019\"]]," + " TOWGS84[0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0], " + " AUTHORITY[\"EPSG\",\"6283\"]], " + " PRIMEM[\"Greenwich\", 0.0, AUTHORITY[\"EPSG\",\"8901\"]]," + " UNIT[\"degree\", 0.017453292519943295], " + " AXIS[\"Geodetic latitude\", NORTH], " + " AXIS[\"Geodetic longitude\", EAST], " + " AXIS[\"Ellipsoidal height\", UP], " + " AUTHORITY[\"EPSG\",\"4939\"]]"; CoordinateReferenceSystem gda94 = CRS.parseWKT(wkt); GeometryFactory gf = new GeometryFactory(); Point point = gf.createPoint( new Coordinate(-16.4463909341494, 130.882672103999, 97.009018073082)); Point world = (Point) JTS.toGeographic(point, gda94); assertEquals(point.getX(), world.getY(), 0.00000005); assertEquals(point.getY(), world.getX(), 0.00000005); }
public void testWithoutGmlProperties() throws Exception { Element feature = GML3MockData.feature(document, document); feature.setAttributeNS(GML.NAMESPACE, "id", "fid.1"); SimpleFeature f = (SimpleFeature) parse(); assertNotNull(feature); assertEquals("fid.1", f.getID()); Point p = (Point) f.getDefaultGeometry(); assertNotNull(p); assertEquals(1.0, p.getX(), 0d); assertEquals(2.0, p.getY(), 0d); Integer i = (Integer) f.getAttribute("count"); assertNotNull(i); assertEquals(1, i.intValue()); }
Point geometry = (Point) reprojectedFeature.getDefaultGeometry(); checkDoubleValue(geometry.getX(), 222638.9816, 0.0001); checkDoubleValue(geometry.getY(), 111325.1429, 0.0001);