Package org.geotools.renderer.crs

Source Code of org.geotools.renderer.crs.TransverseMercatorHandlerFactory

/*
*    GeoTools - The Open Source Java GIS Toolkit
*    http://geotools.org
*
*    (C) 2002-2008, Open Source Geospatial Foundation (OSGeo)
*
*    This library is free software; you can redistribute it and/or
*    modify it under the terms of the GNU Lesser General Public
*    License as published by the Free Software Foundation;
*    version 2.1 of the License.
*
*    This library is distributed in the hope that it will be useful,
*    but WITHOUT ANY WARRANTY; without even the implied warranty of
*    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
*    Lesser General Public License for more details.
*/
package org.geotools.renderer.crs;

import org.geotools.geometry.jts.ReferencedEnvelope;
import org.geotools.referencing.CRS;
import org.geotools.referencing.crs.DefaultGeographicCRS;
import org.geotools.referencing.operation.projection.MapProjection;
import org.geotools.referencing.operation.projection.TransverseMercator;
import org.geotools.referencing.operation.projection.MapProjection.AbstractProvider;
import org.opengis.referencing.FactoryException;
import org.opengis.referencing.crs.CoordinateReferenceSystem;

/**
* Returns a {@link ProjectionHandler} for the {@link TransverseMercator} projection
* that will cut geometries 45° away from the projection central meridian 
*
* @author Andrea Aime - OpenGeo
*
*
* @source $URL$
*/
public class TransverseMercatorHandlerFactory implements ProjectionHandlerFactory {

    public ProjectionHandler getHandler(ReferencedEnvelope renderingEnvelope, CoordinateReferenceSystem sourceCrs, boolean wrap, int maxWraps) throws FactoryException {
        MapProjection mapProjection = CRS.getMapProjection(renderingEnvelope
                .getCoordinateReferenceSystem());
        if (renderingEnvelope != null && mapProjection instanceof TransverseMercator) {
            double centralMeridian = mapProjection.getParameterValues().parameter(
                    AbstractProvider.CENTRAL_MERIDIAN.getName().getCode()).doubleValue();

            ReferencedEnvelope validArea = new ReferencedEnvelope(centralMeridian - 45,
                    centralMeridian + 45, -90, 90, DefaultGeographicCRS.WGS84);

            return new ProjectionHandler(sourceCrs, validArea, renderingEnvelope);
        }

        return null;
    }

}
TOP

Related Classes of org.geotools.renderer.crs.TransverseMercatorHandlerFactory

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.