Package org.geoscript.js.proj

Examples of org.geoscript.js.proj.Projection


            maxY = ((Number) maxYObj).doubleValue();
        }
        if (Double.isNaN(minX) || Double.isNaN(minY) || Double.isNaN(maxX) || Double.isNaN(maxY)) {
            throw new RuntimeException("Config must include minX, minY, maxX, and maxY values.");
        }
        Projection projection = null;
        Object projectionObj = obj.get("projection", obj);
        if (projectionObj instanceof Projection) {
            projection = (Projection) projectionObj;
        } else if (projectionObj instanceof String) {
            projection = new Projection((String) projectionObj);
        }
        CoordinateReferenceSystem crs = projection != null ? projection.unwrap() : null;
        refEnv = new ReferencedEnvelope(minX, maxX, minY, maxY, crs);
    }
View Full Code Here


        if (array.size() == 5) {
            Object crsObj = array.get(4);
            if (crsObj instanceof CoordinateReferenceSystem) {
                crs = (CoordinateReferenceSystem) crsObj;
            } else if (crsObj instanceof String) {
                crs = (new Projection((String) crsObj)).unwrap();
            }
            if (crs == null) {
                throw new RuntimeException("Fifth item must be a Projection instance or a CRS string identifier");
            }
        }
View Full Code Here

        return refEnv.getMaxY();
    }

    @JSGetter
    public Projection getProjection() {
        Projection projection = null;
        CoordinateReferenceSystem crs = refEnv.getCoordinateReferenceSystem();
        if (crs != null) {
            projection = new Projection(this.getParentScope(), crs);
        }
        return projection;
    }
View Full Code Here

    public void setProjection(Object projObj) {
        CoordinateReferenceSystem crs = null;
        if (projObj instanceof Projection) {
            crs = ((Projection) projObj).unwrap();
        } else if (projObj instanceof String) {
            crs = new Projection((String) projObj).unwrap();
        }
        refEnv = new ReferencedEnvelope(refEnv, crs);
    }
View Full Code Here

        return refEnv.getHeight();
    }
   
    @JSFunction
    public Bounds transform(Object projObj) {
        Projection projection = getProjection();
        if (projection == null) {
            throw new RuntimeException("Bounds must have a projection before it can be transformed");
        }
        CoordinateReferenceSystem crs = null;
        if (projObj instanceof Projection) {
            crs = ((Projection) projObj).unwrap();
        } else if (projObj instanceof String) {
            crs = (new Projection((String) projObj)).unwrap();
        }
        if (crs == null) {
            throw new RuntimeException("Argument must be a Projection instance or string identifier.");
        }
        Bounds bounds = null;
View Full Code Here

   
    @JSFunction
    public Bounds intersection(Bounds other) {
        Envelope intersection = refEnv.intersection(sameProjection(other).unwrap());
        CoordinateReferenceSystem crs = null;
        Projection projection = getProjection();
        if (projection != null) {
            crs = projection.unwrap();
        }
        ReferencedEnvelope interRefEnv = new ReferencedEnvelope(intersection, crs);
        if (intersection.isNull()) {
            interRefEnv.setToNull();
        }
View Full Code Here

        Scriptable obj = super.getConfig();
        obj.put("minX", obj, getMinX());
        obj.put("maxX", obj, getMaxX());
        obj.put("minY", obj, getMinY());
        obj.put("maxY", obj, getMaxY());
        Projection projection = getProjection();
        if (projection != null) {
            obj.put("projection", obj, projection.getId());
        }
        return obj;
    }
View Full Code Here

        return obj;
    }
   
    private Bounds sameProjection(Bounds other) {
        Bounds same = other;
        Projection otherProj = other.getProjection();
        if (otherProj != null) {
            if (!otherProj.equals(getProjection())) {
                same = this.transform(otherProj.unwrap());
            }
        }
        return same;
    }
View Full Code Here

     * @return
     */
    public String toFullString() {
        String repr = "[" + getMinX().toString() + ", " + getMinY().toString() +
            ", " + getMaxX().toString() + ", " + getMaxY().toString() + "]";
        Projection projection = getProjection();
        if (projection != null) {
            repr += " " + projection.getId();
        }
        return repr;
    }
View Full Code Here

        return (Point) geom;
    }
   
    @JSFunction
    public Geometry transform(Object projObj) {
        Projection fromProj = projection;
        if (fromProj == null) {
            throw new RuntimeException("Geometry must have a projection before transforming.");
        }
        Projection toProj = null;
        if (projObj instanceof Projection) {
            toProj = (Projection) projObj;
        } else if (projObj instanceof String) {
            toProj = new Projection(getParentScope(), (String) projObj);
        } else {
            throw new RuntimeException("Argument must be a Projection instance or string identifier.");
        }
        GeometryCoordinateSequenceTransformer gt = new GeometryCoordinateSequenceTransformer();
        try {
            gt.setMathTransform(CRS.findMathTransform(fromProj.unwrap(), toProj.unwrap()));
        } catch (FactoryException e) {
            throw new RuntimeException("Failed to find transform.", e);
        }
        com.vividsolutions.jts.geom.Geometry transGeom;
        try {
View Full Code Here

TOP

Related Classes of org.geoscript.js.proj.Projection

Copyright © 2018 www.massapicom. 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.