Package chunmap.model.crs.proj

Source Code of chunmap.model.crs.proj.ReProjOp

/**
* Copyright (c) 2009-2011, chunquedong(YangJiandong)
*
* This file is part of ChunMap project
* Licensed under the GNU LESSER GENERAL PUBLIC LICENSE(Version >=3)
*
* History:
*     2010-05-05  Jed Young  Creation
*/
package chunmap.model.crs.proj;

import chunmap.data.feature.Feature;
import chunmap.data.feature.FeatureCollection;
import chunmap.data.feature.LayerMetadata;
import chunmap.data.feature.VisitAction;
import chunmap.model.crs.CoordinateRef;
import chunmap.view.layer.Layer;
import chunmap.view.layer.LayerCollection;
import chunmap.view.layer.VectorLayer;

public class ReProjOp {
  public static void changeCRS(FeatureCollection fc,CoordinateRef target)
    {
        CoordinateRef source = fc.getMetadata().getCrs();
        final ReProjection rp = new ReProjection(target, source);

        fc.each(new VisitAction(){
      @Override
      public void execute(Feature f) {
        rp.execute(f);
      }});

        fc.setMetadata(new LayerMetadata
            (fc.getMetadata().getName(),fc.getMetadata().getType(),target));
        fc.reComputeEnvelope();
    }

    public static void changeMapCRS(LayerCollection layers, CoordinateRef target)
    {
      for(Layer layer:layers.getLayers()){
            if (layer instanceof VectorLayer)
            {
                VectorLayer vl = (VectorLayer)layer;
                changeCRS(vl.getFeatures(), target);
            }
        }
        layers.reComputeEnvelop();
    }
}
TOP

Related Classes of chunmap.model.crs.proj.ReProjOp

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.