Examples of LineString


Examples of com.vividsolutions.jts.geom.LineString

  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

Examples of com.vividsolutions.jts.geom.LineString

    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

Examples of com.vividsolutions.jts.geom.LineString

    // 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

Examples of org.geolatte.geom.LineString

        if (singlePoint) {
            return createPoint(0);

        } else if (singleLine) {
            PointSequence points = createPoints(0, 2);
            return new LineString(points);

        } else {
            // figures
            int numberOfFigures = dis.readInt();
            figures = readFigures(dis, numberOfFigures);
View Full Code Here

Examples of org.geomajas.gwt.client.spatial.geometry.LineString

        Coordinate[] coordinates = ring.getCoordinates();
        Coordinate firstCoordinate = coordinates[0];
        Coordinate lastCoordinate = coordinates[coordinates.length - 2];

        LineString lineString1 = geometry.getGeometryFactory().createLineString(
            new Coordinate[] { getTransformer().worldToPan(lastCoordinate), getPanPosition(event) });
        tempLine1.setGeometry(lineString1);

        LineString lineString2 = geometry.getGeometryFactory().createLineString(
            new Coordinate[] { getTransformer().worldToPan(firstCoordinate), getPanPosition(event) });
        tempLine2.setGeometry(lineString2);

        mapWidget.render(tempLine1, RenderGroup.VECTOR, RenderStatus.ALL);
        mapWidget.render(tempLine2, RenderGroup.VECTOR, RenderStatus.ALL);
View Full Code Here

Examples of org.geomajas.gwt.client.spatial.geometry.LineString

    IButton button2 = new IButton(I18nProvider.getSampleMessages().renderingDrawLineString());
    button2.addClickHandler(new ClickHandler() {

      public void onClick(ClickEvent event) {
        map.getVectorContext().drawGroup(map.getGroup(RenderGroup.SCREEN), group2);
        LineString geometry = map.getMapModel().getGeometryFactory().createLineString(
            new Coordinate[] { new Coordinate(60, 20), new Coordinate(120, 80), new Coordinate(80, 100) });
        ShapeStyle style = new ShapeStyle("#994488", 0.0f, "#993388", 1, 2);
        map.getVectorContext().drawLine(group2, "LineString", geometry, style);
      }
    });
View Full Code Here

Examples of org.geomajas.gwt.client.spatial.geometry.LineString

    Coordinate[] worldCoords = geometry.getCoordinates();
    for (int i = 0; i < srCoords.length; i++) {
      srCoords[i] = getTransformer().worldToPan(worldCoords[i]);
    }

    LineString lineString = geometry.getGeometryFactory().createLineString(srCoords);
    tempLine.setGeometry(lineString);
  }
View Full Code Here

Examples of org.geomajas.gwt.client.spatial.geometry.LineString

    if (oldCoords != null && oldCoords.length > 0) {
      Coordinate[] newCoords = new Coordinate[oldCoords.length + 1];
      System.arraycopy(oldCoords, 0, newCoords, 0, oldCoords.length);
      newCoords[oldCoords.length] = getPanPosition(event);

      LineString lineString = geometry.getGeometryFactory().createLineString(newCoords);
      tempLineEnd.setGeometry(lineString);
      mapWidget.render(tempLineEnd, RenderGroup.VECTOR, RenderStatus.UPDATE);
    }
  }
View Full Code Here

Examples of org.geomajas.gwt.client.spatial.geometry.LineString

              Coordinate[] coordinates = new Coordinate[4];
              coordinates[0] = new Coordinate(10, y);
              coordinates[1] = new Coordinate(10 + 10, y + 5);
              coordinates[2] = new Coordinate(10 + 5, y + 10);
              coordinates[3] = new Coordinate(10 + 15, y + 15);
              LineString line = mapModel.getGeometryFactory().createLineString(coordinates);
              graphics.drawLine(parentGroup, "style" + lineCount, line, style);
            } else if (vLayer.getLayerInfo().getLayerType() == LayerType.POLYGON
                || vLayer.getLayerInfo().getLayerType() == LayerType.MULTIPOLYGON) {
              // Polygons: draw a rectangle:
              Bbox rect = new Bbox(10, y, 16, 16);
View Full Code Here

Examples of org.geomajas.gwt.client.spatial.geometry.LineString

    graphics.drawLine(parent, name + ".area", lineString, lineStringStyle);

    // Draw individual edges:
    Coordinate[] coordinates = lineString.getCoordinates();
    for (int i = 1; i < coordinates.length; i++) {
      LineString edge = lineString.getGeometryFactory().createLineString(
          new Coordinate[] { coordinates[i - 1], coordinates[i] });
      graphics.drawLine(parent, name + ".edge" + i, edge, edgeStyle);
    }

    // Draw individual vertices:
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.