view src/java/de/intevation/mxd/reader/MapReader.java @ 34:7a927921eb6c

Removed needless imports.
author Raimund Renkert <rrenkert@intevation.de>
date Tue, 12 Apr 2011 13:29:47 +0200
parents c51376f8e24c
children f807c9c81019
line wrap: on
line source
package de.intevation.mxd.reader;

import java.io.IOException;

import org.apache.log4j.Logger;

import com.esri.arcgis.carto.IMap;
import com.esri.arcgis.geometry.ISpatialReference;
import com.esri.arcgis.geometry.ProjectedCoordinateSystem;
import com.esri.arcgis.geometry.GeographicCoordinateSystem;
import com.esri.arcgis.geometry.UnknownCoordinateSystem;
import com.esri.arcgis.geometry.Projection;

import org.w3c.dom.Element;

import de.intevation.mxd.utils.MapToXMLUtils;

/**
 * Reads map information.
 *
 * @author <a href="mailto:raimund.renkert@intevation.de">Raimund Renkert</a>
 */
public class MapReader{

    //Member
    private IMap map;
    private MapToXMLUtils util;

    private static final Logger logger = Logger.getLogger(MapReader.class);

    //Constructor
    public MapReader(IMap map){
        logger.debug("constructor()");
        this.map = map;
    }


    //Methods

    /**
     * Reads the Map attributes.
     */
    public void read() throws IOException{
        logger.debug("read()");
        if(util == null)
            throw new IOException("Can not write to document.");

//        XMLUtils.ElementCreator creator = new XMLUtils.ElementCreator(document,
//                                                                      "", "");
        Element mapElement;
        try{
            mapElement = util.createMap();
        }
        catch(Exception e){
            e.printStackTrace();
            return;
        }
        ISpatialReference sr = map.getSpatialReference();
        logger.debug("Instance: " + sr.getClass().toString());
        if(sr instanceof ProjectedCoordinateSystem){
            ProjectedCoordinateSystem pcs = (ProjectedCoordinateSystem)sr;
            Projection p = (Projection)pcs.getProjection();
            mapElement.setAttribute("projection", p.getName());
        }
        else if(sr instanceof GeographicCoordinateSystem){
            GeographicCoordinateSystem gcs = (GeographicCoordinateSystem)sr;
            mapElement.setAttribute("projection", gcs.getName());
        }
        else if(sr instanceof UnknownCoordinateSystem) {
            UnknownCoordinateSystem ucs = (UnknownCoordinateSystem)sr;
            mapElement.setAttribute("projection", sr.getName());
        }
        else{
            throw new IOException("Unknown SpatialReference: " +
                                  sr.getClass().toString());
        }
    }

    public void setUtil(MapToXMLUtils util){
        this.util = util;
    }
}
// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :
This site is hosted by Intevation GmbH (Datenschutzerklärung und Impressum | Privacy Policy and Imprint)