Package chunmap.model.crs

Source Code of chunmap.model.crs.BLGrid

/**
* 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;

import java.util.ArrayList;
import java.util.List;

import chunmap.data.provider.LayerFactory;
import chunmap.model.coord.Coordinate2D;
import chunmap.model.coord.CPoint;
import chunmap.model.geom.Geometry;
import chunmap.model.geom.LineString;
import chunmap.view.layer.VectorLayer;
/**
* longitude and latitude Grid
* @author YangJiandong
*
*/
public class BLGrid {
  public VectorLayer createGrid()
    {
        List<Geometry> geometrys = new ArrayList<Geometry>();
        addGeometry(geometrys);

        VectorLayer layer = LayerFactory.createGeometryLayer(geometrys);
        return layer;
    }
    private void addGeometry(List<Geometry> geometrys)
    {
        //-180<x>180
        //-90<y>90
        for (int i = -90; i <= 90; i += 10)
        {
            addWeiXian(geometrys, i);
        }
        for (int i = -180; i <= 180; i += 10)
        {
            addJingXian(geometrys, i);
        }
    }

    private void addWeiXian(List<Geometry> geometrys, double weidu)
    {
        LineString ls = new LineString(
            new CPoint[] { new Coordinate2D(-180, weidu), new Coordinate2D(180, weidu) });
        geometrys.add(ls);
    }

    private void addJingXian(List<Geometry> geometrys, double jingdu)
    {
        LineString ls = new LineString(
            new CPoint[] { new Coordinate2D(jingdu, -90), new Coordinate2D(jingdu, 90) });
        geometrys.add(ls);
    }
}
TOP

Related Classes of chunmap.model.crs.BLGrid

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.