comparison src/java/de/intevation/mxd/reader/FeatureLayerReader.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 191b7d18c79e
children e8021f3e411a
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.FeatureClassName; 29 import com.esri.arcgis.geodatabase.FeatureClassName;
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;
228 catch(IOException ioe) { 233 catch(IOException ioe) {
229 logger.warn( 234 logger.warn(
230 "Could not read extent from layer " 235 "Could not read extent from layer "
231 + layer.getName() + "."); 236 + layer.getName() + ".");
232 } 237 }
238 //Read the projection.
239 try {
240 ISpatialReference sr = layer.getSpatialReference();
241 int projection = 0;
242 if(sr instanceof ProjectedCoordinateSystem) {
243 ProjectedCoordinateSystem pcs = (ProjectedCoordinateSystem)sr;
244 projection = pcs.getFactoryCode();
245 }
246 else if(sr instanceof GeographicCoordinateSystem) {
247 GeographicCoordinateSystem gcs = (GeographicCoordinateSystem)sr;
248 projection = gcs.getFactoryCode();
249 }
250 else if(sr instanceof UnknownCoordinateSystem) {
251 UnknownCoordinateSystem ucs = (UnknownCoordinateSystem)sr;
252 projection = 0;
253 }
254 else{
255 logger.debug(
256 "Unknown SpatialReference: " +
257 sr.getClass().toString());
258 }
259
260 if(projection == 0) {
261 logger.warn(
262 "Unknown projection for Layer:" + layer.getName() +
263 " Please edit projection in resulting mapfile.");
264 }
265 layerElement.setAttribute("projection", String.valueOf(projection));
266 }
267 catch(IOException ioe) {
268 logger.warn("Could not read layer projection.");
269 }
270
233 try { 271 try {
234 String datatype = layer.getDataSourceType(); 272 String datatype = layer.getDataSourceType();
235 if(layer.getWorkspace().getType() == 0) { 273 if(layer.getWorkspace().getType() == 0) {
236 layerElement.setAttribute("connection_type", "local"); 274 layerElement.setAttribute("connection_type", "local");
237 layerElement.setAttribute( 275 layerElement.setAttribute(
This site is hosted by Intevation GmbH (Datenschutzerklärung und Impressum | Privacy Policy and Imprint)