Java 类com.vividsolutions.jts.geom.CoordinateSequenceFilter 实例源码

项目:sumo    文件:EditGeometryVectorLayer.java   
public void mouseDragged(final Point initPosition, final Point imagePosition, int button,Object graphContext) {
    if (selectedGeometry == null | !this.edit | this.move | this.add | this.delete) {
        return;
    }
    if (!selectedGeometry.contains(gf.createPoint(new Coordinate(initPosition.x, initPosition.y)))) {
        selectedGeometry = null;
        return;
    }
    if (type.equals(GeometryImage.POLYGON) || type.equals(GeometryImage.LINESTRING)) {
        selectedGeometry.apply(new CoordinateSequenceFilter() {

            public void filter(CoordinateSequence seq, int i) {
                if (i == seq.size() - 1) {
                    if (seq.getCoordinate(i) == seq.getCoordinate(0)) {
                        return;
                    }
                }
                seq.getCoordinate(i).x += imagePosition.x - initPosition.x;
                seq.getCoordinate(i).y += imagePosition.y - initPosition.y;
            }

            public boolean isDone() {
                return false;
            }

            public boolean isGeometryChanged() {
                return true;
            }
        });
    }

}
项目:gama    文件:DynamicLineString.java   
@Override
public void apply(final CoordinateSequenceFilter filter) {
    final CoordinateSequence points = getCoordinateSequence();
    filter.filter(points, 0);
    if (filter.isDone()) {
        return;
    }
    filter.filter(points, 1);
    if (filter.isGeometryChanged()) {
        geometryChanged();
    }
}
项目:gama    文件:Spatial.java   
@operator (
        value = { "set_z" },
        category = { IOperatorCategory.SPATIAL, IOperatorCategory.THREED },
        concept = {})
@doc (
        value = "Sets the z ordinate of each point of a geometry to the value provided, in order, by the right argument",
        examples = { @example ("shape <- triangle(3) set_z [5,10,14];") },
        see = {})
public static IShape set_z(final IScope scope, final IShape geom, final IContainer<?, Double> coords) {
    if (geom == null) { return null; }
    final Geometry g = geom.getInnerGeometry();
    if (g == null) { return geom; }
    if (coords == null || coords.isEmpty(scope)) { return null; }
    if (coords.length(scope) > g.getNumPoints()) { throw GamaRuntimeException
            .warning("Trying to modify a point outside the bounds of the geometry", scope); }
    final Double[] zs = coords.listValue(scope, Types.FLOAT, false).toArray(new Double[0]);
    g.apply(new CoordinateSequenceFilter() {

        @Override
        public void filter(final CoordinateSequence seq, final int i) {
            if (i <= zs.length - 1) {
                seq.getCoordinate(i).z = zs[i];
            }
        }

        @Override
        public boolean isDone() {
            return false;
        }

        @Override
        public boolean isGeometryChanged() {
            return true;
        }
    });

    return geom;
}
项目:sumo    文件:ClipProcess.java   
List<PointDistance> gatherElevationPointCloud(Geometry geom) {
    final List<PointDistance> results = new ArrayList<PointDistance>();
    geom.apply(new CoordinateSequenceFilter() {

        @Override
        public boolean isGeometryChanged() {
            return false;
        }

        @Override
        public boolean isDone() {
            return false;
        }

        @Override
        public void filter(CoordinateSequence seq, int i) {
            // we do all the collecting when called for the first ordinate
            if(i > 0) {
                return;
            }
            // collects only points with a Z
            if(hasElevations(seq)) {
                Coordinate[] coords = seq.toCoordinateArray();
                for (int j = 0; j < coords.length; j++) {
                    Coordinate c = coords[j];
                    // avoid adding the last element of a ring to avoid un-balancing the 
                    // weights (the fist/last coordinate would be counted twice)
                    if((j < coords.length - 1 || !c.equals(coords[0])) && !Double.isNaN(c.z)) {
                        results.add(new PointDistance(c));
                    }
                }
            }
        }

    });

    if(results.size() == 0) {
        return null;
    } else {
        return results;
    }
}
项目:gama    文件:Spatial.java   
@operator (
        value = { "set_z" },
        category = { IOperatorCategory.SPATIAL, IOperatorCategory.THREED },
        concept = { IConcept.GEOMETRY, IConcept.SPATIAL_COMPUTATION, IConcept.POINT, IConcept.THREED })
@doc (
        value = "Sets the z ordinate of the n-th point of a geometry to the value provided by the third argument",
        masterDoc = true,
        examples = { @example ("loop i from: 0 to: length(shape.points) - 1{"
                + "set shape <-  set_z (shape, i, 3.0);" + "}") },
        see = {})
public static IShape set_z(final IScope scope, final IShape geom, final Integer index, final Double z) {
    if (geom == null) { return null; }
    final Geometry g = geom.getInnerGeometry();
    if (g == null) { return geom; }
    if (index < 0 || index > g.getNumPoints() - 1) { throw GamaRuntimeException
            .warning("Trying to modify a point outside the bounds of the geometry", scope); }
    g.apply(new CoordinateSequenceFilter() {

        boolean done = false;

        @Override
        public void filter(final CoordinateSequence seq, final int i) {
            if (i == index) {
                seq.getCoordinate(i).z = z;
                done = true;
            }
        }

        @Override
        public boolean isDone() {
            return done;
        }

        @Override
        public boolean isGeometryChanged() {
            return done;
        }
    });

    return geom;
}
项目:GeoSpark    文件:Circle.java   
@Override
public void apply(CoordinateSequenceFilter filter) {
    // Do nothing. This circle is not expected to be a complete geometry.       
}