First, let me say that I think I'm being dense, this has to have been solved and my google fu is not up to finding an example.
The problem I'm trying to solve is the intersection of a Polygon and a LineString where one or both cross the antimeridian, or I should say that in WGS84 they don't. If I'm understanding what needs to be done, is that I need to reproject the WGS84 polygon and linestring into some other CRS that is centered on the antimeridian before I call Polygon.intersect(linestring) From the CRS docs ( http://docs.geotools.org/latest/userguide/library/referencing/crs.html ) it seems that if I have the wkt for a CRS centered on the antimeridian, I should be able to do something like this: Polygon pSrc = ... LineString lSrc = ... CoordinateReferenceSystem sourceCRS = CRS.decode("EPSG:4326"); String wkt = "GEOGCS[" + "\"WGS 84\"," + " DATUM[" + " \"WGS_1984\"," + " SPHEROID[\"WGS 84\",6378137,298.257223563,AUTHORITY[\"EPSG\",\"7030\"]]," + " TOWGS84[0,0,0,0,0,0,0]," + " AUTHORITY[\"EPSG\",\"6326\"]]," + " PRIMEM[\"Greenwich\",0,AUTHORITY[\"EPSG\",\"8901\"]]," + " UNIT[\"DMSH\",0.0174532925199433,AUTHORITY[\"EPSG\",\"9108\"]]," + " AXIS[\"Lat\",NORTH]," + " AXIS[\"Long\",EAST]," + " AUTHORITY[\"EPSG\",\"4326\"]]"; CoordinateReferenceSystem targetCRS = CRS.parseWKT(wkt); MathTransform mathTransform = CRS.findMathTransform(sourceCrs, targetCRS, false); Geometry pTrn = JTS.transform( pSrc, transform); Geometry lTrn = JTS.transform( lSrc, transform); Geometry result = pTrn.intersection(lTrn); I took the naive approach and simply set the PRIMEM to 180 which as I expected, failed. It got answers, but they were way off, like wrong hemisphere off. Am I completely out to lunch here? Does anyone know where a proper WGS 84 compatible CRS centered on the antimeridian is stored? Or maybe the WKT for one? ------------------------------------------------------------------------------ See everything from the browser to the database with AppDynamics Get end-to-end visibility with application monitoring from AppDynamics Isolate bottlenecks and diagnose root cause in seconds. Start your free trial of AppDynamics Pro today! http://pubads.g.doubleclick.net/gampad/clk?id=48808831&iu=/4140/ostg.clktrk _______________________________________________ GeoTools-GT2-Users mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users
