public void setUserData(Object userData) { point.setUserData(userData); }
/** * Set point attributes into its user data to be encoded in Geoserver: gml:id, srsName, * srsDimension, axisLabels and uomLabels. * * @param point The point object * @param crs Coordinate System object * @param srsName srs name * @param gmlId gml:id value */ private void setUserData(Point geom, CoordinateReferenceSystem crs, String gmlId) { Map<Object, Object> userData = new HashMap<Object, Object>(); if (gmlId != null) { userData.put("gml:id", gmlId); } if (crs != null) { userData.put(CoordinateReferenceSystem.class, crs); } geom.setUserData(userData); } }
private Point parsePoint(int dimension, CoordinateReferenceSystem crs) throws XmlPullParserException, IOException, NoSuchAuthorityCodeException, FactoryException { parser.require(START_TAG, GML.NAMESPACE, GML.Point.getLocalPart()); crs = crs(crs); Point geom; parser.nextTag(); parser.require(START_TAG, GML.NAMESPACE, null); Coordinate point; if (GML.pos.getLocalPart().equals(parser.getName())) { Coordinate[] coords = parseCoordList(dimension); point = coords[0]; parser.nextTag(); } else if (GML.coordinates.getLocalPart().equals(parser.getName())) { Coordinate[] coords = parseCoordinates(dimension); point = coords[0]; parser.nextTag(); } else if (GML.coord.getLocalPart().equals(parser.getName())) { point = parseCoord(); parser.nextTag(); } else { throw new IllegalStateException( "Unknown coordinate element for Point: " + parser.getName()); } parser.require(END_TAG, GML.NAMESPACE, GML.Point.getLocalPart()); geom = geomFac.createPoint(point); geom.setUserData(crs); return geom; }
private Point parsePoint(int dimension, CoordinateReferenceSystem crs) throws XmlPullParserException, IOException, NoSuchAuthorityCodeException, FactoryException { parser.require(START_TAG, GML.NAMESPACE, GML.Point.getLocalPart()); crs = crs(crs); Point geom; parser.nextTag(); parser.require(START_TAG, GML.NAMESPACE, null); Coordinate point; if (GML.pos.getLocalPart().equals(parser.getName())) { Coordinate[] coords = parseCoordList(dimension, crs); point = coords[0]; parser.nextTag(); } else if (GML.coordinates.getLocalPart().equals(parser.getName())) { Coordinate[] coords = parseCoordinates(dimension, crs); point = coords[0]; parser.nextTag(); } else if (GML.coord.getLocalPart().equals(parser.getName())) { point = parseCoord(); parser.nextTag(); } else { throw new IllegalStateException( "Unknown coordinate element for Point: " + parser.getName()); } parser.require(END_TAG, GML.NAMESPACE, GML.Point.getLocalPart()); geom = geomFac.createPoint(point); geom.setUserData(crs); return geom; }
/** * Generates the point. * * @param geometryFactory Geometry factory to be used to create the point. * @return Created Point. */ public Geometry create(GeometryFactory geometryFactory) { Point point = geometryFactory.createPoint(coordinate); point.setUserData(getSRS()); point.setSRID(getSRID()); return point; } }
/** * @param point * @throws TransformException */ public Point transformPoint(Point point, GeometryFactory gf) throws TransformException { // if required, init csTransformer using geometry's CSFactory init(gf); CoordinateSequence cs = projectCoordinateSequence(point.getCoordinateSequence()); Point transformed = gf.createPoint(cs); transformed.setUserData(point.getUserData()); return transformed; }
public static Point point() { Point p = gf.createPoint(new Coordinate(1, 2)); p.setUserData(crs()); return p; }
for (int i = 0; i < features; i++) { Point point = gf.createPoint(new Coordinate(x + i, y + i)); point.setUserData(DefaultGeographicCRS.WGS84);
for (int i = 0; i < features; i++) { Point point = gf.createPoint(new Coordinate(x + i, y + i)); point.setUserData(crs);
private Point parsePoint(int dimension, CoordinateReferenceSystem crs) throws XmlPullParserException, IOException, NoSuchAuthorityCodeException, FactoryException { parser.require(START_TAG, GML.NAMESPACE, GML.Point.getLocalPart()); crs = crs(crs); Point geom; parser.nextTag(); parser.require(START_TAG, GML.NAMESPACE, null); Coordinate point; if (GML.pos.getLocalPart().equals(parser.getName())) { Coordinate[] coords = parseCoordList(dimension, crs); point = coords[0]; parser.nextTag(); } else if (GML.coordinates.getLocalPart().equals(parser.getName())) { Coordinate[] coords = parseCoordinates(dimension, crs); point = coords[0]; parser.nextTag(); } else if (GML.coord.getLocalPart().equals(parser.getName())) { point = parseCoord(); parser.nextTag(); } else { throw new IllegalStateException( "Unknown coordinate element for Point: " + parser.getName()); } parser.require(END_TAG, GML.NAMESPACE, GML.Point.getLocalPart()); geom = geomFac.createPoint(point); geom.setUserData(crs); return geom; }
private Point parsePoint(int dimension, CoordinateReferenceSystem crs) throws XmlPullParserException, IOException, NoSuchAuthorityCodeException, FactoryException { parser.require(START_TAG, GML.NAMESPACE, GML.Point.getLocalPart()); crs = crs(crs); Point geom; parser.nextTag(); parser.require(START_TAG, GML.NAMESPACE, null); Coordinate point; if (GML.pos.getLocalPart().equals(parser.getName())) { Coordinate[] coords = parseCoordList(dimension); point = coords[0]; parser.nextTag(); } else if (GML.coordinates.getLocalPart().equals(parser.getName())) { Coordinate[] coords = parseCoordinates(dimension); point = coords[0]; parser.nextTag(); } else if (GML.coord.getLocalPart().equals(parser.getName())) { point = parseCoord(); parser.nextTag(); } else { throw new IllegalStateException( "Unknown coordinate element for Point: " + parser.getName()); } parser.require(END_TAG, GML.NAMESPACE, GML.Point.getLocalPart()); geom = geomFac.createPoint(point); geom.setUserData(crs); return geom; }
/** * @param point * * @throws TransformException */ public Point transformPoint(final Point point, final GeometryFactory gf) throws TransformException { final CoordinateSequence cs = projectCoordinateSequence(point.getCoordinateSequence()); final Point transformed = gf.createPoint(cs); transformed.setUserData( point.getUserData() ); return transformed; }
@Test public void testCRSAccessMap() throws NoSuchAuthorityCodeException, FactoryException{ final CoordinateReferenceSystem epsg4326 = CommonCRS.WGS84.geographic(); final Point geom = GF.createPoint(new Coordinate(50, 27)); //should not raise a log CoordinateReferenceSystem crs = JTS.findCoordinateReferenceSystem(geom); assertNull(crs); final Map<String,Object> map = new HashMap<String, Object>(); map.put(HintsPending.JTS_GEOMETRY_CRS, epsg4326); geom.setUserData(map); crs = JTS.findCoordinateReferenceSystem(geom); assertEquals(epsg4326, crs); }
@Test public void testCRSAccessDirect() throws FactoryException{ final CoordinateReferenceSystem epsg4326 = CommonCRS.WGS84.geographic(); final Point geom = GF.createPoint(new Coordinate(50, 27)); //should not raise a log CoordinateReferenceSystem crs = JTS.findCoordinateReferenceSystem(geom); assertNull(crs); geom.setUserData(epsg4326); crs = JTS.findCoordinateReferenceSystem(geom); assertEquals(epsg4326, crs); }
@Test public void testSetCRS(){ //empty user data test final Point geom = GF.createPoint(new Coordinate(50, 27)); final CoordinateReferenceSystem crs = CommonCRS.WGS84.normalizedGeographic(); JTS.setCRS(geom, crs); final Object userData = geom.getUserData(); assertEquals(crs, userData); //user data contained another CRS final Point geom2 = GF.createPoint(new Coordinate(50, 27)); geom2.setUserData(CommonCRS.SPHERE.normalizedGeographic()); JTS.setCRS(geom2, crs); final Object userData2 = geom2.getUserData(); assertEquals(crs, userData2); //user data contained a Map with another CRS final Point geom3 = GF.createPoint(new Coordinate(50, 27)); Map<String,CoordinateReferenceSystem> dataMap = new HashMap<String,CoordinateReferenceSystem>(); dataMap.put(HintsPending.JTS_GEOMETRY_CRS, CommonCRS.SPHERE.normalizedGeographic()); geom3.setUserData(dataMap); JTS.setCRS(geom3, crs); final Object userData3 = geom3.getUserData(); Map values = (Map) userData3; assertEquals(crs, values.get(HintsPending.JTS_GEOMETRY_CRS)); }