From: Rueben S. <r_j...@ya...> - 2005-01-13 04:33:07
|
Hi, I am not exactly clear what you are doing, but I assume that you have a shapefile with a geographic coordinate reference system (CRS) (longitude (x) values from -180 to +180). Geographic coordinates (longitude, latitude) are difficult to work with, since they wrap around on the globe, but not on a flat map that you are displaying. You could project it to a mercator CRS for display (or some other projection). The central meridian of the projection would be the desired centre of your map. This will work correctly for points, but unfortunately the re-projected polygon geometries will be very messed up. Some points in the same geometry will likely end up at opposite sides of the map (also note that the mercator projection is undefined at the poles). Unfortunately the solution to this problem is not easy. I think that besides just re-projecting the points in a polygon, polygons that now get split over the outer edge of the map (ie England if your map centre is +180 degrees longitude) need to have their geometries modified. They need to be intersected with a line along the prime meridian (in the England case) to split the polygon into two parts (one part on either end of the map). Also polygons that were split onto two different sides of the shapefile (eastern russia or alaska) will need to be merged together. This last step is not required, but would make things look nicer. I think that code to do all of this does not belong in the coordinate transformation codebase of geotools, but instead belongs in the CRSServices class where geometries are being re-projected. Unfortunately getting the above ideas working correctly for all cases will be a lot of work. For example, the orthographic projection is undefined outside of the hemisphere of the projection centre, so in this case, the undefined boundary needs to be calculated (it will be a circle or ellipse) and intersected with all the re-projected polygons that straddle this boundary. The correct thing to do for each map projection is probably going to be a bit different. Also, for your problem, you could start to simply re-calculate the points for your shapefile (add 180 to all of them and subtract 360 from points that are now > 180 (to keep everything within +-180)). This should result in the dateline as your centre (it is now longitude 0), but you will run into the same problem as above, with some geometries split over both ends of your map. Good luck, and remember that any general solution to this problem (or feedback on my above thoughts) would be great. The ability to re-project world maps correctly would be a nice addition to geotools. Unfortunately 95% of map re-projection does not need this ability, so it is a low priority for us right now. Also note that we do not have any map projections implemented that are suitable for displaying the entire world well (such as the gall stereographic). Rueben On Wed, 2005-12-01 at 14:32 -0500, Philip Oliver-Paull wrote: > Hi. I'm working on a project that uses a map of the entire world. We > would like to be able to center the map on any point on the earth and > still have the rest of the world visible on either side of the point. > This would be most helpful for center points in the pacific, but the > shapefile doesn't wrap and just drops off at the dateline. It appears > that the coordinate system keeps going on past 180 degrees longitude, as > well. Is there any way to get the coordinate system and shapefile to wrap? > > Thanks in advance, > > Phil > > > ------------------------------------------------------- > The SF.Net email is sponsored by: Beat the post-holiday blues > Get a FREE limited edition SourceForge.net t-shirt from ThinkGeek. > It's fun and FREE -- well, almost....http://www.thinkgeek.com/sfshirt > _______________________________________________ > Geotools-gt2-users mailing list > Geo...@li... > https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users |