Package com.vividsolutions.jts.geom

Examples of com.vividsolutions.jts.geom.LineString


    request.setQueryType(SearchByLocationRequest.QUERY_INTERSECTS);
    request.setSearchType(SearchByLocationRequest.SEARCH_ALL_LAYERS);
    request.setLayerIds(new String[] {LAYER_ID});

    GeometryFactory factory = new GeometryFactory();
    LineString equator = factory.createLineString(new Coordinate[] {new Coordinate(0, 0),
        new Coordinate(-180, 180)});
    request.setLocation(converter.toDto(equator));

    // execute
    SearchByLocationResponse response = (SearchByLocationResponse) dispatcher.execute(
View Full Code Here


    //note that setting a global filter on the SearchByLocationRequest will only work if the filter is applicable
    //to all layers! In this test case there is only one layer.
    request.setFilter("region='Region 1'");

    GeometryFactory factory = new GeometryFactory();
    LineString equator = factory.createLineString(new Coordinate[] {new Coordinate(0, 0),
        new Coordinate(-180, 180)});
    request.setLocation(converter.toDto(equator));

    // execute
    SearchByLocationResponse response = (SearchByLocationResponse) dispatcher.execute(
View Full Code Here

    request.setSearchType(SearchByLocationRequest.SEARCH_ALL_LAYERS);
    request.setLayerIds(new String[] {LAYER_ID});
    request.setFilter(LAYER_ID, "region='Region 1'");

    GeometryFactory factory = new GeometryFactory();
    LineString equator = factory.createLineString(new Coordinate[] {new Coordinate(0, 0),
        new Coordinate(-180, 180)});
    request.setLocation(converter.toDto(equator));

    // execute
    SearchByLocationResponse response = (SearchByLocationResponse) dispatcher.execute(
View Full Code Here

  }
 
  @Test
  public void testGetBoundsIntersectsFiltered() throws Exception {
    GeometryFactory factory = new GeometryFactory();
    LineString equator = factory.createLineString(new Coordinate[] { new Coordinate(0, 0),
        new Coordinate(-180, 180) });
    Filter filter = filterService.createIntersectsFilter(equator,beanLayer.getLayerInfo().getFeatureInfo().getGeometryType().getName());
    Envelope bounds = layerService.getBounds(LAYER_ID,
        geoService.getCrs2(beanLayer.getLayerInfo().getCrs()), filter);
    Assert.assertEquals(0, bounds.getMinX(), ALLOWANCE);
View Full Code Here

          List<Coordinate> coords = new ArrayList<Coordinate>();
          coords.add(new Coordinate(0, 0));
          coords.add(new Coordinate(0.75 * w, 0.25 * h));
          coords.add(new Coordinate(0.25 * w, 0.75 * h));
          coords.add(new Coordinate(w, h));
          LineString linestring = geometryFactory.createLineString(
              coords.toArray(new Coordinate[coords.size()]));
          line = new LiteShape2(linestring, null, null, false);
        }
        return line;
      } else if (symbolizer instanceof PolygonSymbolizer) {
View Full Code Here

      for (int i = 0; i < mpoint.getNumGeometries(); i++) {
        drawGeometry(mpoint.getGeometryN(i), symbol);
      }
    } else if (g instanceof Polygon) {
      Polygon poly = (Polygon) g;
      LineString shell = poly.getExteriorRing();
      int nHoles = poly.getNumInteriorRing();
      drawPathContent(shell.getCoordinates());
      for (int j = 0; j < nHoles; j++) {
        drawPathContent(poly.getInteriorRingN(j).getCoordinates());
      }
      template.closePathEoFillStroke();
    } else if (g instanceof LineString) {
      LineString line = (LineString) g;
      drawPathContent(line.getCoordinates());
      template.stroke();
    } else if (g instanceof Point) {
      Point point = (Point) g;
      drawPoint(point.getCoordinate(), symbol);
      template.fillStroke();
View Full Code Here

  public void testLineString() throws MarshallException, GeomajasException {
    GeometryFactory factory = new GeometryFactory(new PrecisionModel(10000.0), 31300);
    CoordinateArraySequence coords = new CoordinateArraySequence(new Coordinate[] { new Coordinate(12.0, 34.23),
        new Coordinate(12.000, 54.555), new Coordinate(-0.01, 0.0) });
    LineString p = new LineString(coords, factory);
    JSONObject jtsJson = (JSONObject) jtsSerializer.marshall(null, p);
    Geometry dto = converter.toDto(p);
    JSONObject dtoJson = (JSONObject) dtoSerializer.marshall(null, dto);
    Assert.assertEquals(jtsJson.toString(), dtoJson.toString());
  }
View Full Code Here

  public void testMultiLineString() throws MarshallException, GeomajasException {
    GeometryFactory factory = new GeometryFactory(new PrecisionModel(10000.0), 31300);
    CoordinateArraySequence coords = new CoordinateArraySequence(new Coordinate[] { new Coordinate(12.0, 34.23),
        new Coordinate(12.000, 54.555), new Coordinate(-0.01, 0.0) });
    LineString l = new LineString(coords, factory);
    MultiLineString m = new MultiLineString(new LineString[] { l }, factory);
    JSONObject jtsJson = (JSONObject) jtsSerializer.marshall(null, m);
    Geometry dto = converter.toDto(m);
    JSONObject dtoJson = (JSONObject) dtoSerializer.marshall(null, dto);
    Assert.assertEquals(jtsJson.toString(), dtoJson.toString());
View Full Code Here

    coordinates = checkIfClosed(coordinates);
    return factory.createLinearRing(coordinates);
  }

  private LineString createLineString(GeometryFactory factory, JSONObject jso) throws UnmarshallException {
    LineString geometry;
    JSONArray jsonCoords = jso.getJSONArray(ATTRIBUTE_COORDINATES);
    if (jsonCoords == null) {
      throw new UnmarshallException("coordinates missing");
    }
    Coordinate[] coordinates = new Coordinate[jsonCoords.length()];
    for (int i = 0; i < jsonCoords.length(); i++) {
      JSONObject nextCoord = jsonCoords.getJSONObject(i);
      if (nextCoord == null) {
        throw new UnmarshallException("inner coordinate missing");
      }
      coordinates[i] = new Coordinate(nextCoord.getDouble("x"), nextCoord.getDouble("y"));
    }
    geometry = new LineString(new CoordinateArraySequence(coordinates), factory);
    return geometry;
  }
View Full Code Here

    // Convert to the polygons precision model:
    jtsGeometry = converter.toInternal(request.getSplitter());
    if (!(jtsGeometry instanceof LineString)) {
      throw new GeomajasException(ExceptionCode.UNEXPECTED_PROBLEM, "splitter has to be a LineString");
    }
    LineString preciseLine = (LineString) jtsGeometry;
    int precision = polygon.getPrecisionModel().getMaximumSignificantDigits() - 1;
    com.vividsolutions.jts.geom.Geometry bufferedLine = preciseLine.buffer(Math.pow(10.0, -precision));
    com.vividsolutions.jts.geom.Geometry diff = polygon.difference(bufferedLine);

    if (diff instanceof Polygon) {
      response.setGeometries(new Geometry[] { converter.toDto(diff) });
    } else if (diff instanceof MultiPolygon) {
View Full Code Here

TOP

Related Classes of com.vividsolutions.jts.geom.LineString

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.