Package org.geoscript.js.proj

Examples of org.geoscript.js.proj.Projection


        return projection;
    }
   
    @JSSetter
    public void setProjection(Object projObj) {
        Projection projection = null;
        if (projObj != null) {
            if (projObj instanceof Projection) {
                projection = (Projection) projObj;
            } else if (projObj instanceof String) {
                projection = new Projection(getParentScope(), (String) projObj);
            } else {
                throw ScriptRuntime.constructError("Error", "Set projection with Projection object or string identifier.");
            }
            if (this.projection != null && !projection.equals(this.projection)) {
                throw ScriptRuntime.constructError("Error", "Geometry projection already set.  Use the transform method to transform coordinates.");
            }
        }
        this.projection = projection;
    }
View Full Code Here


            return wrapped;
        }
    }

    private Geometry sameProjection(Geometry thisGeom, Geometry otherGeom) {
        Projection thisProj = thisGeom.projection;
        if (thisProj != null) {
            Projection otherProj = otherGeom.projection;
            if (otherProj != null) {
                if (!thisProj.equals(otherProj)) {
                    otherGeom = otherGeom.transform(thisProj);
                }
            }
View Full Code Here

            }
            Scriptable fieldConfig = cx.newObject(scope);
            fieldConfig.put("name", fieldConfig, name);
            fieldConfig.put("type", fieldConfig, typeName);
            if (jsValue instanceof Geometry) {
                Projection projection = ((Geometry) jsValue).getProjection();
                if (projection != null) {
                    fieldConfig.put("projection", fieldConfig, projection.getId());
                }
            }
            Field field = new Field(scope, (NativeObject) fieldConfig);
            fields.put(i, fields, field);
        }
View Full Code Here

        if (config.has("projection", config)) {
            Object projObj = config.get("projection", config);
            if (projObj instanceof Projection) {
                crs = ((Projection) projObj).unwrap();
            } else if (projObj instanceof String) {
                crs = new Projection(getParentScope(), (String) projObj).unwrap();
            } else if (projObj != null){
                throw ScriptRuntime.constructError("Error", "Invalid projection object.");
            }
        }
        if (crs != null) {
View Full Code Here

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

        Scriptable config = super.getConfig();
        Context cx = getCurrentContext();
        Scriptable def = cx.newObject(getParentScope());
        def.put("name", def, getName());
        def.put("type", def, getType());
        Projection projection = getProjection();
        if (projection != null) {
            def.put("projection", def, projection.getId());
        }
        config.put("def", config, def);
        return config;
    }
View Full Code Here

        set(name, geometry);
    }
   
    @JSGetter
    public Projection getProjection() {
        Projection projection = null;
        SimpleFeatureType featureType = feature.getFeatureType();
        GeometryDescriptor descriptor = featureType.getGeometryDescriptor();
        if (descriptor != null) {
            CoordinateReferenceSystem crs = descriptor.getCoordinateReferenceSystem();
            if (crs != null) {
                projection = new Projection(getParentScope(), crs);
            }
        }
        return projection;
    }
View Full Code Here

        String geomName = getGeometryName();
        if (geomName != null && geomName.equals(name)) {
            if (!(value instanceof Geometry)) {
                throw ScriptRuntime.constructError("Error", "Attempted to set geometry property to a non-geometry object: " + Context.toString(value));
            }
            Projection featureProj = getProjection();
            Geometry geometry = (Geometry) value;
            Projection geomProj = geometry.getProjection();
            if (featureProj != null) {
                if (geomProj != null) {
                    if (!featureProj.equals(geometry.getProjection())) {
                        value = geometry.transform(featureProj);
                    }
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.