Mercurial > mxd2map > mxd2map
changeset 170:b9ee44070056
Manage projections and units.
author | vc11884admin@VC11884.win.bsh.de |
---|---|
date | Wed, 06 Jul 2011 15:17:05 +0200 |
parents | d7c8493cb345 |
children | bf1ba2e06991 929e09649b08 |
files | ChangeLog src/java/de/intevation/mxd/reader/MapReader.java src/java/de/intevation/mxd/writer/MapScriptWriter.java |
diffstat | 3 files changed, 41 insertions(+), 28 deletions(-) [+] |
line wrap: on
line diff
--- a/ChangeLog Tue Jul 05 17:52:24 2011 +0200 +++ b/ChangeLog Wed Jul 06 15:17:05 2011 +0200 @@ -1,3 +1,12 @@ +2011-07-06 Raimund Renkert <raimund.renkert@intevation.de> + + * src/java/de/intevation/mxd/reader/MapReader.java: + Read the projection as EPSG code from the MXD file. + + * src/java/de/intevation/mxd/writer/MapScriptWriter.java: + Write the EPSG code to the mapfile and set the correct units to map + and layer. + 2011-07-05 Raimund Renkert <raimund.renkert@intevation.de> * src/java/de/intevation/mxd/writer/MapScriptWriter.java:
--- a/src/java/de/intevation/mxd/reader/MapReader.java Tue Jul 05 17:52:24 2011 +0200 +++ b/src/java/de/intevation/mxd/reader/MapReader.java Wed Jul 06 15:17:05 2011 +0200 @@ -152,19 +152,18 @@ //Read the projection. try { ISpatialReference sr = map.getSpatialReference(); - String projection = ""; + int projection = 0; if(sr instanceof ProjectedCoordinateSystem) { ProjectedCoordinateSystem pcs = (ProjectedCoordinateSystem)sr; - Projection p = (Projection)pcs.getProjection(); - projection = p.getName(); + projection = pcs.getFactoryCode(); } else if(sr instanceof GeographicCoordinateSystem) { GeographicCoordinateSystem gcs = (GeographicCoordinateSystem)sr; - projection = gcs.getName(); + projection = gcs.getFactoryCode(); } else if(sr instanceof UnknownCoordinateSystem) { UnknownCoordinateSystem ucs = (UnknownCoordinateSystem)sr; - projection = ucs.getName(); + projection = 0; } else{ logger.debug( @@ -172,12 +171,12 @@ sr.getClass().toString()); } - if(projection.equals("Unknown")) { + if(projection == 0) { logger.warn( "Unknown projection." + " Please edit projection in resulting mapfile."); } - mapElement.setAttribute("projection", projection); + mapElement.setAttribute("projection", String.valueOf(projection)); } catch(IOException ioe) { logger.warn(
--- a/src/java/de/intevation/mxd/writer/MapScriptWriter.java Tue Jul 05 17:52:24 2011 +0200 +++ b/src/java/de/intevation/mxd/writer/MapScriptWriter.java Wed Jul 06 15:17:05 2011 +0200 @@ -42,6 +42,7 @@ private String mapFilename; private String MS_BINDIR = "c:/ms_6.1-dev/bin"; private String prefix = ""; + private MS_UNITS units = MS_UNITS.MS_METERS; public MapScriptWriter() { map = new mapObj(""); @@ -101,33 +102,36 @@ Double.parseDouble(mapNode.getAttribute("extent_max_y"))); //Set the units. - String units = mapNode.getAttribute("units"); - MS_UNITS msu; - if(units.equals("feet")) { - msu = MS_UNITS.MS_FEET; - } - else if(units.equals("inches")) { - msu = MS_UNITS.MS_INCHES; - } - else if(units.equals("kilometers")) { - msu = MS_UNITS.MS_KILOMETERS; + map.setProjection("epsg:" + mapNode.getAttribute("projection")); + String u = mapNode.getAttribute("units"); + if(u.equals("feet")) { + units = MS_UNITS.MS_FEET; } - else if(units.equals("meters")) { - msu = MS_UNITS.MS_METERS; - } - else if(units.equals("miles")) { - msu = MS_UNITS.MS_MILES; + else if(u.equals("inches")) { + units = MS_UNITS.MS_INCHES; } - else if(units.equals("nauticalmiles")) { - msu = MS_UNITS.MS_NAUTICALMILES; + else if(u.equals("kilometers")) { + units = MS_UNITS.MS_KILOMETERS; } - else if(units.equals("points")) { - msu = MS_UNITS.MS_PIXELS; + else if(u.equals("meters")) { + units = MS_UNITS.MS_METERS; } + else if(u.equals("miles")) { + units = MS_UNITS.MS_MILES; + } + else if(u.equals("nauticalmiles")) { + units = MS_UNITS.MS_NAUTICALMILES; + } + else if(u.equals("points")) { + units = MS_UNITS.MS_PIXELS; + } + else if(u.equals("degree")) { + units = MS_UNITS.MS_DD; + } else { - msu = MS_UNITS.MS_METERS; + units = MS_UNITS.MS_METERS; } - map.setUnits(msu); + map.setUnits(units); //TODO: Find out whats the correct scale value. //map.setScaledenom(Double.parseDouble(mapNode.getAttribute("scale"))); @@ -151,6 +155,7 @@ String lname = layerElement.getAttribute("name"); lname = lname.replaceAll(" ", ""); layer.setName(lname); + layer.setUnits(units.swigValue()); layer.setMetaData("wms_title", layerElement.getAttribute("name")); if(layerElement.hasAttribute("group")) { layer.setGroup(layerElement.getAttribute("group"));