Search in sources :

Example 26 with Envelope

use of com.vividsolutions.jts.geom.Envelope in project sldeditor by robward-scisys.

the class MapRender method mouseWheelMoved.

/**
 * Mouse wheel moved.
 *
 * @param ev the mousewheel event
 */
@Override
public void mouseWheelMoved(MouseWheelEvent ev) {
    int clicks = ev.getWheelRotation();
    // -ve means wheel moved up, +ve means down
    int sign = (clicks < 0 ? -1 : 1);
    Envelope env = mapPane.getDisplayArea();
    double width = env.getWidth();
    double delta = width * clickToZoom * sign;
    env.expandBy(delta);
    mapPane.setDisplayArea((org.opengis.geometry.Envelope) env);
    switch(geometryType) {
        case RASTER:
            {
                ReferencedEnvelope refEnv = ReferencedEnvelope.create(env, gridCoverage.getCoordinateReferenceSystem());
                wmsEnvVarValues.setMapBounds(refEnv);
            }
            break;
        case POINT:
        case LINE:
        case POLYGON:
            {
                ReferencedEnvelope refEnv = ReferencedEnvelope.create(env, featureList.getSchema().getCoordinateReferenceSystem());
                wmsEnvVarValues.setMapBounds(refEnv);
            }
            break;
        default:
            break;
    }
    EnvironmentVariableManager.getInstance().setWMSEnvVarValues(wmsEnvVarValues);
    clearLabelCache();
    mapPane.repaint();
}
Also used : ReferencedEnvelope(org.geotools.geometry.jts.ReferencedEnvelope) ReferencedEnvelope(org.geotools.geometry.jts.ReferencedEnvelope) Envelope(com.vividsolutions.jts.geom.Envelope)

Example 27 with Envelope

use of com.vividsolutions.jts.geom.Envelope in project sldeditor by robward-scisys.

the class EnvironmentVariableManagerTest method testSetWMSEnvVarValues.

/**
 * Test method for
 * {@link com.sldeditor.filter.v2.envvar.EnvironmentVariableManager#setWMSEnvVarValues(com.sldeditor.filter.v2.envvar.WMSEnvVarValues)}.
 */
@Test
public void testSetWMSEnvVarValues() {
    EnvironmentVariableManager.getInstance().setWMSEnvVarValues(null);
    WMSEnvVarValues wmsEnvVar = new WMSEnvVarValues();
    wmsEnvVar.setImageHeight(42);
    wmsEnvVar.setImageWidth(454);
    Envelope envelope = new Envelope(1.0, 2.0, 50.0, 51.1);
    ReferencedEnvelope mapBounds = ReferencedEnvelope.create(envelope, CoordManager.getInstance().getWGS84());
    wmsEnvVar.setMapBounds(mapBounds);
    EnvironmentVariableManager.getInstance().setWMSEnvVarValues(wmsEnvVar);
    // Update the values again
    WMSEnvVarValues wmsEnvVar2 = new WMSEnvVarValues();
    wmsEnvVar2.setImageHeight(69);
    wmsEnvVar2.setImageWidth(123);
    Envelope envelope2 = new Envelope(-1.0, -2.0, 50.0, 51.1);
    ReferencedEnvelope mapBounds2 = ReferencedEnvelope.create(envelope2, CoordManager.getInstance().getWGS84());
    wmsEnvVar2.setMapBounds(mapBounds2);
    EnvironmentVariableManager.getInstance().setWMSEnvVarValues(wmsEnvVar2);
}
Also used : ReferencedEnvelope(org.geotools.geometry.jts.ReferencedEnvelope) WMSEnvVarValues(com.sldeditor.filter.v2.envvar.WMSEnvVarValues) ReferencedEnvelope(org.geotools.geometry.jts.ReferencedEnvelope) Envelope(com.vividsolutions.jts.geom.Envelope) Test(org.junit.Test)

Example 28 with Envelope

use of com.vividsolutions.jts.geom.Envelope in project incubator-rya by apache.

the class GeoWaveGTQueryTest method executeBoundingBoxQueryTest.

@Test
public void executeBoundingBoxQueryTest() throws IOException {
    System.out.println("Constructing bounding box for the area contained by [Baltimore, MD and Richmond, VA.");
    final Geometry boundingBox = GeometryUtils.GEOMETRY_FACTORY.toGeometry(new Envelope(BALTIMORE, RICHMOND));
    System.out.println("Executing query, expecting to match ALL points...");
    final QueryOptions queryOptions = new QueryOptions(ADAPTER, INDEX);
    final SpatialQuery spatialQuery = new SpatialQuery(boundingBox);
    try (final CloseableIterator<SimpleFeature> iterator = dataStore.query(queryOptions, spatialQuery)) {
        int count = 0;
        while (iterator.hasNext()) {
            System.out.println("Query match: " + iterator.next().getID());
            count++;
        }
        System.out.println("executeBoundingBoxQueryTest count: " + count);
        // Should match "FedEx Field", "Washington Monument", and "White House"
        assertEquals(3, count);
    }
}
Also used : Geometry(com.vividsolutions.jts.geom.Geometry) SpatialQuery(mil.nga.giat.geowave.core.geotime.store.query.SpatialQuery) Envelope(com.vividsolutions.jts.geom.Envelope) QueryOptions(mil.nga.giat.geowave.core.store.query.QueryOptions) SimpleFeature(org.opengis.feature.simple.SimpleFeature) Test(org.junit.Test)

Example 29 with Envelope

use of com.vividsolutions.jts.geom.Envelope in project ili2db by claeis.

the class Iox2fgdb method surface2wkb.

/**
 * Converts a SURFACE to a JTS Polygon.
 * @param obj INTERLIS SURFACE structure
 * @param strokeP maximum stroke to use when removing ARCs
 * @return JTS Polygon
 * @throws Iox2wkbException
 */
public byte[] surface2wkb(// SurfaceOrAreaType type)
IomObject polygonObj, // SurfaceOrAreaType type)
boolean asCurvePolygon, // SurfaceOrAreaType type)
double strokeP, // SurfaceOrAreaType type)
int srsId) throws IoxException {
    if (polygonObj == null) {
        return null;
    }
    byte[] ret = null;
    Polygon polygon = Iox2jtsext.surface2JTS(polygonObj, strokeP);
    os.reset();
    if (asCurvePolygon) {
        int shapeType = EsriShpConstants.ShapeGeneralPolygon;
        shapeType |= EsriShpConstants.shapeHasCurves;
        shapeType |= (outputDimension == 3 ? EsriShpConstants.shapeHasZs : 0);
        os.writeInt(shapeType);
    } else {
        if (outputDimension == 3) {
            os.writeInt(EsriShpConstants.ShapePolygonZ);
        } else {
            os.writeInt(EsriShpConstants.ShapePolygon);
        }
    }
    // boundingBox
    Envelope env = polygon.getEnvelopeInternal();
    os.writeDouble(env.getMinX());
    os.writeDouble(env.getMinY());
    os.writeDouble(env.getMaxX());
    os.writeDouble(env.getMaxY());
    // cParts The number of rings in the polygon.
    // cPoints The total number of points for all parts.
    int cPart = 1;
    int cPoints = getNumPoints(polygon.getExteriorRing());
    int holec = polygon.getNumInteriorRing();
    cPart += holec;
    for (int holei = 0; holei < holec; holei++) {
        cPoints += getNumPoints(polygon.getInteriorRingN(holei));
    }
    os.writeInt(cPart);
    os.writeInt(cPoints);
    // parts[cParts] An array of length NumParts. Stores, for each Ring, the index of its
    // first point in the points array. Array indexes are with respect to 0.
    int partStart = 0;
    os.writeInt(partStart);
    partStart += getNumPoints(polygon.getExteriorRing());
    for (int holei = 0; holei < holec; holei++) {
        os.writeInt(partStart);
        partStart += getNumPoints(polygon.getInteriorRingN(holei));
    }
    java.util.ArrayList<Arc> arcs = null;
    if (asCurvePolygon) {
        arcs = new java.util.ArrayList<Arc>();
    }
    java.util.ArrayList<Double> zv = null;
    if (outputDimension == 3) {
        zv = new java.util.ArrayList<Double>();
    }
    double[] zMin = new double[1];
    double[] zMax = new double[1];
    {
        Coordinate coord = polygon.getExteriorRing().getStartPoint().getCoordinate();
        if (outputDimension == 3) {
            zMin[0] = coord.z;
            zMax[0] = coord.z;
        }
    }
    // shell is always in clockwise order
    // holes are in a counterclockwise direction
    LineString polyline = polygon.getExteriorRing();
    int startPtIdx = 0;
    polyline = asOneLine(polyline);
    if (CGAlgorithms.isCCW(polyline.getCoordinates())) {
        polyline = (LineString) polyline.reverse();
    }
    writePoints(polyline, false, zv, zMin, zMax, startPtIdx, arcs);
    startPtIdx += getNumPoints(polyline);
    for (int holei = 0; holei < holec; holei++) {
        polyline = polygon.getInteriorRingN(holei);
        polyline = asOneLine(polyline);
        if (!CGAlgorithms.isCCW(polyline.getCoordinates())) {
            polyline = (LineString) polyline.reverse();
        }
        writePoints(polyline, true, zv, zMin, zMax, startPtIdx, arcs);
        startPtIdx += getNumPoints(polyline);
    }
    if (outputDimension == 3) {
        // zMin
        os.writeDouble(zMin[0]);
        // zMax
        os.writeDouble(zMax[0]);
        // Zs[cPoints]
        for (Double z : zv) {
            os.writeDouble(z);
        }
    }
    if (asCurvePolygon) {
        writeArcs(arcs);
    }
    ret = os.toByteArray();
    return ret;
}
Also used : Coordinate(com.vividsolutions.jts.geom.Coordinate) LineString(com.vividsolutions.jts.geom.LineString) Polygon(com.vividsolutions.jts.geom.Polygon) Envelope(com.vividsolutions.jts.geom.Envelope)

Example 30 with Envelope

use of com.vividsolutions.jts.geom.Envelope in project ili2db by claeis.

the class Iox2fgdb method multisurface2wkb.

public byte[] multisurface2wkb(// SurfaceOrAreaType type)
IomObject multisurfaceObj, // SurfaceOrAreaType type)
boolean asCurvePolygon, // SurfaceOrAreaType type)
double strokeP, // SurfaceOrAreaType type)
int srsId) throws IoxException {
    if (multisurfaceObj == null) {
        return null;
    }
    byte[] ret = null;
    os.reset();
    if (asCurvePolygon) {
        int shapeType = EsriShpConstants.ShapeGeneralPolygon;
        shapeType |= EsriShpConstants.shapeHasCurves;
        shapeType |= (outputDimension == 3 ? EsriShpConstants.shapeHasZs : 0);
        os.writeInt(shapeType);
    } else {
        if (outputDimension == 3) {
            os.writeInt(EsriShpConstants.ShapePolygonZ);
        } else {
            os.writeInt(EsriShpConstants.ShapePolygon);
        }
    }
    java.util.ArrayList<Polygon> polygons = new java.util.ArrayList<Polygon>();
    // boundingBox
    Envelope env = new Envelope();
    int surfacec = multisurfaceObj.getattrvaluecount("surface");
    for (int surfacei = 0; surfacei < surfacec; surfacei++) {
        IomObject surface = multisurfaceObj.getattrobj("surface", surfacei);
        IomObject iomSurfaceClone = new ch.interlis.iom_j.Iom_jObject("MULTISURFACE", null);
        iomSurfaceClone.addattrobj("surface", surface);
        Polygon polygon = Iox2jtsext.surface2JTS(iomSurfaceClone, strokeP);
        polygons.add(polygon);
        env.expandToInclude(polygon.getEnvelopeInternal());
    }
    os.writeDouble(env.getMinX());
    os.writeDouble(env.getMinY());
    os.writeDouble(env.getMaxX());
    os.writeDouble(env.getMaxY());
    // cParts The number of rings in the multisurface.
    // cPoints The total number of points for all parts.
    int cPart = 0;
    int cPoints = 0;
    for (Polygon polygon : polygons) {
        cPart += 1;
        cPoints += getNumPoints(polygon.getExteriorRing());
        int holec = polygon.getNumInteriorRing();
        cPart += holec;
        for (int holei = 0; holei < holec; holei++) {
            cPoints += getNumPoints(polygon.getInteriorRingN(holei));
        }
    }
    os.writeInt(cPart);
    os.writeInt(cPoints);
    // parts[cParts] An array of length NumParts. Stores, for each Ring, the index of its
    // first point in the points array. Array indexes are with respect to 0.
    int partStart = 0;
    for (Polygon polygon : polygons) {
        os.writeInt(partStart);
        partStart += getNumPoints(polygon.getExteriorRing());
        int holec = polygon.getNumInteriorRing();
        for (int holei = 0; holei < holec; holei++) {
            os.writeInt(partStart);
            partStart += getNumPoints(polygon.getInteriorRingN(holei));
        }
    }
    java.util.ArrayList<Arc> arcs = null;
    if (asCurvePolygon) {
        arcs = new java.util.ArrayList<Arc>();
    }
    java.util.ArrayList<Double> zv = null;
    if (outputDimension == 3) {
        zv = new java.util.ArrayList<Double>();
    }
    double[] zMin = new double[1];
    double[] zMax = new double[1];
    {
        Coordinate coord = polygons.get(0).getExteriorRing().getStartPoint().getCoordinate();
        if (outputDimension == 3) {
            zMin[0] = coord.z;
            zMax[0] = coord.z;
        }
    }
    int startPtIdx = 0;
    for (Polygon polygon : polygons) {
        // shell is always in clockwise order
        // holes are in a counterclockwise direction
        LineString polyline = polygon.getExteriorRing();
        polyline = asOneLine(polyline);
        if (CGAlgorithms.isCCW(polyline.getCoordinates())) {
            polyline = (LineString) polyline.reverse();
        }
        writePoints(polyline, false, zv, zMin, zMax, startPtIdx, arcs);
        startPtIdx += getNumPoints(polyline);
        int holec = polygon.getNumInteriorRing();
        for (int holei = 0; holei < holec; holei++) {
            polyline = polygon.getInteriorRingN(holei);
            polyline = asOneLine(polyline);
            if (!CGAlgorithms.isCCW(polyline.getCoordinates())) {
                polyline = (LineString) polyline.reverse();
            }
            writePoints(polyline, true, zv, zMin, zMax, startPtIdx, arcs);
            startPtIdx += getNumPoints(polyline);
        }
    }
    if (outputDimension == 3) {
        // zMin
        os.writeDouble(zMin[0]);
        // zMax
        os.writeDouble(zMax[0]);
        // Zs[cPoints]
        for (Double z : zv) {
            os.writeDouble(z);
        }
    }
    if (asCurvePolygon) {
        writeArcs(arcs);
    }
    ret = os.toByteArray();
    return ret;
}
Also used : ArrayList(java.util.ArrayList) Envelope(com.vividsolutions.jts.geom.Envelope) IomObject(ch.interlis.iom.IomObject) Coordinate(com.vividsolutions.jts.geom.Coordinate) LineString(com.vividsolutions.jts.geom.LineString) Polygon(com.vividsolutions.jts.geom.Polygon)

Aggregations

Envelope (com.vividsolutions.jts.geom.Envelope)111 Coordinate (com.vividsolutions.jts.geom.Coordinate)21 Node (org.locationtech.geogig.api.Node)16 Geometry (com.vividsolutions.jts.geom.Geometry)13 ObjectId (org.locationtech.geogig.api.ObjectId)13 ReferencedEnvelope (org.geotools.geometry.jts.ReferencedEnvelope)12 STRtree (com.vividsolutions.jts.index.strtree.STRtree)11 ArrayList (java.util.ArrayList)11 Vertex (org.opentripplanner.routing.graph.Vertex)11 Test (org.junit.Test)9 NodeRef (org.locationtech.geogig.api.NodeRef)9 Edge (org.opentripplanner.routing.graph.Edge)9 LineString (com.vividsolutions.jts.geom.LineString)8 RevTree (org.locationtech.geogig.api.RevTree)8 TransitStop (org.opentripplanner.routing.vertextype.TransitStop)7 Map (java.util.Map)6 RevFeatureType (org.locationtech.geogig.api.RevFeatureType)6 StreetEdge (org.opentripplanner.routing.edgetype.StreetEdge)6 RevFeature (org.locationtech.geogig.api.RevFeature)5 AgencyAndId (org.onebusaway.gtfs.model.AgencyAndId)5