Hello, I am trying to determine if a point on the earth is within a polygon and I am having some difficulty. I am doing this by using Eclipse and gt-jts-wrapper-2.6.4.jar. The coordinate system is WGS84.
The code in question is the following : Hints hints = new Hints(Hints.CRS, DefaultGeographicCRS.WGS84); PositionFactory positionFactory = GeometryFactoryFinder.getPositionFactory(hints); GeometryFactory geometryFactory = GeometryFactoryFinder.getGeometryFactory(hints); PrimitiveFactory primitiveFactory = GeometryFactoryFinder.getPrimitiveFactory(hints); AggregateFactory aggregateFactory = GeometryFactoryFinder.getAggregateFactory(hints); WKTParser parser = new WKTParser(geometryFactory, primitiveFactory, positionFactory, aggregateFactory); try { // These are lat/long points on the earth. Geometry polygon = parser.parse("POLYGON((0.0 0.0, 0.0 1.0, 1.0 1.0, 1.0 0.0, 0.0 0.0))"); double distance = polygon.distance(parser.parse("POINT( .5 .5)")); } catch (Exception e) { e.printStackTrace(); } Problems : - The coordinate reference system of the primitiveFactory is null, while the crs for the positionFactory, geometryFactory and aggregateFactory is WGS84. I assuming that the crs of the primitiveFactory should be WGS84. - The coordinate reference system of the polygon is null, I assume because the primitiveFactory. I'm assuming that both the polygon and the primitiveFactory should have the same crs as the geometryFactory. Thank you very much for any help in advance. Sincerely, Daniel Sireci
------------------------------------------------------------------------------
_______________________________________________ Geotools-gt2-users mailing list Geotools-gt2-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users