Mercurial > mxd2map
comparison src/java/de/intevation/mxd/reader/RasterLayerReader.java @ 307:f9e53dcc7424
Add Read/Write Support for Projections on a per Layer basis
author | Andre Heinecke <aheinecke@intevation.de> |
---|---|
date | Thu, 06 Sep 2012 18:58:41 +0200 |
parents | ea3fde77ea48 |
children | 5e3a40a84539 |
comparison
equal
deleted
inserted
replaced
306:ea3fde77ea48 | 307:f9e53dcc7424 |
---|---|
28 import com.esri.arcgis.carto.LabelEngineLayerProperties; | 28 import com.esri.arcgis.carto.LabelEngineLayerProperties; |
29 import com.esri.arcgis.geodatabase.RasterDatasetName; | 29 import com.esri.arcgis.geodatabase.RasterDatasetName; |
30 import com.esri.arcgis.system.IName; | 30 import com.esri.arcgis.system.IName; |
31 import com.esri.arcgis.system.IPropertySet; | 31 import com.esri.arcgis.system.IPropertySet; |
32 import com.esri.arcgis.geometry.Envelope; | 32 import com.esri.arcgis.geometry.Envelope; |
33 import com.esri.arcgis.geometry.ISpatialReference; | |
34 import com.esri.arcgis.geometry.ProjectedCoordinateSystem; | |
35 import com.esri.arcgis.geometry.GeographicCoordinateSystem; | |
36 import com.esri.arcgis.geometry.UnknownCoordinateSystem; | |
37 import com.esri.arcgis.geometry.Projection; | |
33 | 38 |
34 import org.w3c.dom.Element; | 39 import org.w3c.dom.Element; |
35 | 40 |
36 import de.intevation.mxd.utils.MapToXMLUtils; | 41 import de.intevation.mxd.utils.MapToXMLUtils; |
37 import java.io.IOException; | 42 import java.io.IOException; |
147 "Could not read datasource." + | 152 "Could not read datasource." + |
148 " Stopped reading layer " + layer.getName() + "."); | 153 " Stopped reading layer " + layer.getName() + "."); |
149 util.removeLayer(layerElement); | 154 util.removeLayer(layerElement); |
150 return null; | 155 return null; |
151 } | 156 } |
157 try { | |
158 Envelope rect = (Envelope)layer.getExtent(); | |
159 layerElement.setAttribute( | |
160 "extent_min_x", | |
161 String.valueOf(rect.getXMin ())); | |
162 layerElement.setAttribute( | |
163 "extent_max_x", | |
164 String.valueOf(rect.getXMax())); | |
165 layerElement.setAttribute( | |
166 "extent_min_y", | |
167 String.valueOf(rect.getYMin())); | |
168 layerElement.setAttribute( | |
169 "extent_max_y", | |
170 String.valueOf(rect.getYMax())); | |
171 } | |
172 catch(Exception e) { | |
173 logger.warn( | |
174 "Could not read extent from layer " | |
175 + layer.getName() + "."); | |
176 } | |
177 //Read the projection. | |
178 try { | |
179 ISpatialReference sr = layer.getSpatialReference(); | |
180 int projection = 0; | |
181 if(sr instanceof ProjectedCoordinateSystem) { | |
182 ProjectedCoordinateSystem pcs = (ProjectedCoordinateSystem)sr; | |
183 projection = pcs.getFactoryCode(); | |
184 } | |
185 else if(sr instanceof GeographicCoordinateSystem) { | |
186 GeographicCoordinateSystem gcs = (GeographicCoordinateSystem)sr; | |
187 projection = gcs.getFactoryCode(); | |
188 } | |
189 else if(sr instanceof UnknownCoordinateSystem) { | |
190 UnknownCoordinateSystem ucs = (UnknownCoordinateSystem)sr; | |
191 projection = 0; | |
192 } | |
193 else{ | |
194 logger.debug( | |
195 "Unknown SpatialReference: " + | |
196 sr.getClass().toString()); | |
197 } | |
198 | |
199 if(projection == 0) { | |
200 logger.warn( | |
201 "Unknown projection for Layer:" + layer.getName() + | |
202 " Please edit projection in resulting mapfile."); | |
203 } | |
204 layerElement.setAttribute("projection", String.valueOf(projection)); | |
205 } | |
206 catch(Exception e) { | |
207 logger.warn("Could not read layer projection."); | |
208 } | |
152 | 209 |
153 // Static Attributes for Raster: | 210 // Static Attributes for Raster: |
154 layerElement.setAttribute("type", "raster"); | 211 layerElement.setAttribute("type", "raster"); |
155 layerElement.setAttribute("connection_type", "local"); | 212 layerElement.setAttribute("connection_type", "local"); |
156 | 213 |