Package org.geomajas.geometry

Examples of org.geomajas.geometry.Geometry


    if (lineStrings == null) {
      throw new UnmarshallException("lineStrings are missing");
    }
    Geometry[] geometries = new Geometry[lineStrings.length()];
    for (int i = 0; i < lineStrings.length(); i++) {
      Geometry lineString = new Geometry("LineString", geometry.getSrid(), geometry.getPrecision());
      geometries[i] = createLineString(lineString, lineStrings.getJSONObject(i));
    }
    geometry.setGeometries(geometries);
    return geometry;
  }
View Full Code Here


    if (polygons == null) {
      throw new UnmarshallException("polygons are missing");
    }
    Geometry[] geometries = new Geometry[polygons.length()];
    for (int i = 0; i < polygons.length(); i++) {
      Geometry polygon = new Geometry("Polygon", geometry.getSrid(), geometry.getPrecision());
      geometries[i] = createPolygon(polygon, polygons.getJSONObject(i));
    }
    geometry.setGeometries(geometries);
    return geometry;
  }
View Full Code Here

  // -------------------------------------------------------------------------
  // MARSHALL: server-to-client serialization
  // -------------------------------------------------------------------------

  public Object marshall(SerializerState state, Object o) throws MarshallException {
    Geometry geometry = (Geometry) o;
    JSONObject json = null;
    if (geometry.getGeometryType().equals(Geometry.POINT)) {
      json = serializePoint(geometry);
    } else if (geometry.getGeometryType().equals(Geometry.LINE_STRING)) {
      json = serializeLineString(geometry);
    } else if (geometry.getGeometryType().equals(Geometry.LINEAR_RING)) {
      json = serializeLinearRing(geometry);
    } else if (geometry.getGeometryType().equals(Geometry.POLYGON)) {
      json = serializePolygon(geometry);
    } else if (geometry.getGeometryType().equals(Geometry.MULTI_POINT)) {
      json = serializeMultiPoint(geometry);
    } else if (geometry.getGeometryType().equals(Geometry.MULTI_LINE_STRING)) {
      json = serializeMultiLineString(geometry);
    } else if (geometry.getGeometryType().equals(Geometry.MULTI_POLYGON)) {
      json = serializeMultiPolygon(geometry);
    }
    return json;
  }
View Full Code Here

    JSONObject json = new JSONObject();
    putBasics(json, geometry);

    JSONObject shell = null;
    if (geometry.getGeometries() != null && geometry.getGeometries().length > 0) {
      Geometry exteriorRing = geometry.getGeometries()[0];
      exteriorRing.setGeometryType(Geometry.LINE_STRING);
      shell = serializeLinearRing(exteriorRing);
    }
    json.put("shell", shell);

    JSONArray holes = new JSONArray();
    if (geometry.getGeometries() != null && geometry.getGeometries().length > 1) {
      for (int i = 1; i < geometry.getGeometries().length; i++) {
        Geometry interiorRing = geometry.getGeometries()[i];
        interiorRing.setGeometryType(Geometry.LINE_STRING);
        holes.put(serializeLinearRing(interiorRing));
      }
    }
    json.put("holes", holes);
View Full Code Here

  // -------------------------------------------------------------------------

  @Test
  public void gwtPointToDto() {
    // Test GWT Point to DTO:
    Geometry point = GeometryConverter.toDto(createJtsPoint());
    Assert.assertEquals(c1.getX(), point.getCoordinates()[0].getX());
  }
View Full Code Here

  }

  @Test
  public void gwtLineStringToDto() {
    // Test GWT LineString to DTO:
    Geometry lineString = GeometryConverter.toDto(createJtsLineString());
    Assert.assertEquals(c2.getX(), lineString.getCoordinates()[1].getX());
  }
View Full Code Here

  }

  @Test
  public void gwtLinearRingToDto() {
    // Test GWT LinearRing to DTO:
    Geometry linearRing = GeometryConverter.toDto(createJtsLinearRing());
    Assert.assertEquals(c4.getX(), linearRing.getCoordinates()[3].getX());
  }
View Full Code Here

  }

  @Test
  public void gwtPolygonToDto() {
    // Test GWT Polygon to DTO:
    Geometry polygon = GeometryConverter.toDto(createJtsPolygon());
    Assert.assertEquals(c6.getX(), polygon.getGeometries()[1].getCoordinates()[1].getX());
  }
View Full Code Here

  }

  @Test
  public void gwtMultiPointToDto() {
    // Test GWT MultiPoint to DTO:
    Geometry multiPoint = GeometryConverter.toDto(createJtsMultiPoint());
    Assert.assertEquals(c3.getX(), multiPoint.getGeometries()[2].getCoordinates()[0].getX());
  }
View Full Code Here

  }

  @Test
  public void gwtMultiLineStringToDto() {
    // Test GWT MultiLineString to DTO:
    Geometry multiLineString = GeometryConverter.toDto(createJtsMultiLineString());
    Assert.assertEquals(c7.getX(), multiLineString.getGeometries()[1].getCoordinates()[2].getX());
  }
View Full Code Here

TOP

Related Classes of org.geomajas.geometry.Geometry

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.