org.geomajas.geometry.Geometry.getGeometries()方法的使用及代码示例

x33g5p2x  于2022-01-20 转载在 其他  
字(13.1k)|赞(0)|评价(0)|浏览(176)

本文整理了Java中org.geomajas.geometry.Geometry.getGeometries()方法的一些代码示例,展示了Geometry.getGeometries()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Geometry.getGeometries()方法的具体详情如下:
包路径:org.geomajas.geometry.Geometry
类名称:Geometry
方法名:getGeometries

Geometry.getGeometries介绍

暂无

代码示例

代码示例来源:origin: org.geomajas/geomajas-client-gwt2-impl

private void setMultiPolygon(Geometry multiPolygon) {
  if (multiPolygon.getGeometries() != null && multiPolygon.getGeometries().length > 0) {
    setPolygon(multiPolygon.getGeometries()[0]);
    for (int i = 1; i < multiPolygon.getGeometries().length; i++) {
      Geometry polygon = multiPolygon.getGeometries()[i];
      for (int j = 0; j < polygon.getGeometries().length; j++) {
        Geometry ring = polygon.getGeometries()[j];
        Coordinate[] pathCoords = removeLastCoordinate(ring);
        addSubPath(pathCoords, true);
      }
    }
  }
}

代码示例来源:origin: org.geomajas/geomajas-gwt-client-impl

private void setMultiPolygon(Geometry multiPolygon) {
  if (multiPolygon.getGeometries() != null && multiPolygon.getGeometries().length > 0) {
    setPolygon(multiPolygon.getGeometries()[0]);
    for (int i = 1; i < multiPolygon.getGeometries().length; i++) {
      Geometry polygon = multiPolygon.getGeometries()[i];
      for (int j = 0; j < polygon.getGeometries().length; j++) {
        Geometry ring = polygon.getGeometries()[j];
        Coordinate[] pathCoords = removeLastCoordinate(ring);
        addSubPath(pathCoords, true);
      }
    }
  }
}

代码示例来源:origin: org.geomajas/geomajas-gwt-client-impl

private void setMultiLineString(Geometry multiLineString) {
  if (multiLineString.getGeometries() != null && multiLineString.getGeometries().length > 0) {
    setLineString(multiLineString.getGeometries()[0]);
    for (int i = 1; i < multiLineString.getGeometries().length; i++) {
      Geometry lineString = multiLineString.getGeometries()[i];
      addSubPath(clone(lineString.getCoordinates()), false);
    }
  }
}

代码示例来源:origin: org.geomajas/geomajas-client-gwt2-impl

private Group toShapeMultiPoint(Geometry multiPoint) {
  Group group = new Group();
  if (multiPoint.getGeometries() != null && multiPoint.getGeometries().length > 0) {
    for (int i = 0; i < multiPoint.getGeometries().length; i++) {
      Geometry point = multiPoint.getGeometries()[i];
      Shape shape = toShapePoint(point);
      group.add(shape);
    }
    return group;
  }
  return null;
}

代码示例来源:origin: org.geomajas/geomajas-gwt-client-impl

private Group toShapeMultiPoint(Geometry multiPoint) {
  Group group = new Group();
  if (multiPoint.getGeometries() != null && multiPoint.getGeometries().length > 0) {
    for (int i = 0; i < multiPoint.getGeometries().length; i++) {
      Geometry point = multiPoint.getGeometries()[i];
      Shape shape = toShapePoint(point);
      group.add(shape);
    }
    return group;
  }
  return null;
}

代码示例来源:origin: org.geomajas/geomajas-client-gwt2-impl

private void setMultiLineString(Geometry multiLineString) {
  if (multiLineString.getGeometries() != null && multiLineString.getGeometries().length > 0) {
    setLineString(multiLineString.getGeometries()[0]);
    for (int i = 1; i < multiLineString.getGeometries().length; i++) {
      Geometry lineString = multiLineString.getGeometries()[i];
      addSubPath(clone(lineString.getCoordinates()), false);
    }
  }
}

代码示例来源:origin: org.geomajas/geomajas-gwt-client-impl

private void setPolygon(Geometry polygon) {
  if (polygon.getGeometries() != null && polygon.getGeometries().length > 0) {
    setLinearRing(polygon.getGeometries()[0]);
    getElement().getStyle().setProperty("fillRule", "evenOdd");
    for (int i = 1; i < polygon.getGeometries().length; i++) {
      Geometry ring = polygon.getGeometries()[i];
      Coordinate[] pathCoords = removeLastCoordinate(ring);
      addSubPath(pathCoords, true);
    }
  }
}

代码示例来源:origin: org.geomajas.project/geomajas-project-geometry-jts

private static com.vividsolutions.jts.geom.Geometry[] convertGeometries(Geometry geometry,
      com.vividsolutions.jts.geom.Geometry[] geometries) throws JtsConversionException {
    for (int i = 0; i < geometries.length; i++) {
      geometries[i] = toJts(geometry.getGeometries()[i]);
    }
    return geometries;
  }
}

代码示例来源:origin: org.geomajas/geomajas-client-gwt2-impl

private void setPolygon(Geometry polygon) {
  if (polygon.getGeometries() != null && polygon.getGeometries().length > 0) {
    setLinearRing(polygon.getGeometries()[0]);
    getElement().getStyle().setProperty("fillRule", "evenOdd");
    for (int i = 1; i < polygon.getGeometries().length; i++) {
      Geometry ring = polygon.getGeometries()[i];
      Coordinate[] pathCoords = removeLastCoordinate(ring);
      if (pathCoords != null && pathCoords.length > 0) {
        addSubPath(pathCoords, true);
      }
    }
  }
}

代码示例来源:origin: org.geomajas/geomajas-client-gwt2-impl

private Geometry screenToWorld(Geometry geometry) {
  if (geometry != null) {
    Geometry result = new Geometry(geometry.getGeometryType(), geometry.getSrid(), geometry.getPrecision());
    if (geometry.getGeometries() != null) {
      Geometry[] transformed = new Geometry[geometry.getGeometries().length];
      for (int i = 0; i < geometry.getGeometries().length; i++) {
        transformed[i] = screenToWorld(geometry.getGeometries()[i]);
      }
      result.setGeometries(transformed);
    }
    if (geometry.getCoordinates() != null) {
      Coordinate[] transformed = new Coordinate[geometry.getCoordinates().length];
      for (int i = 0; i < geometry.getCoordinates().length; i++) {
        transformed[i] = screenToWorld(geometry.getCoordinates()[i]);
      }
      result.setCoordinates(transformed);
    }
    return result;
  }
  throw new IllegalArgumentException("Cannot transform null geometry.");
}

代码示例来源:origin: org.geomajas/geomajas-client-gwt2-impl

private Geometry worldToScreen(Geometry geometry) {
  if (geometry != null) {
    Geometry result = new Geometry(geometry.getGeometryType(), geometry.getSrid(), geometry.getPrecision());
    if (geometry.getGeometries() != null) {
      Geometry[] transformed = new Geometry[geometry.getGeometries().length];
      for (int i = 0; i < geometry.getGeometries().length; i++) {
        transformed[i] = worldToScreen(geometry.getGeometries()[i]);
      }
      result.setGeometries(transformed);
    }
    if (geometry.getCoordinates() != null) {
      Coordinate[] transformed = new Coordinate[geometry.getCoordinates().length];
      for (int i = 0; i < geometry.getCoordinates().length; i++) {
        transformed[i] = worldToScreen(geometry.getCoordinates()[i]);
      }
      result.setCoordinates(transformed);
    }
    return result;
  }
  throw new IllegalArgumentException("Cannot transform null geometry.");
}

代码示例来源:origin: org.geomajas/geomajas-gwt-client-impl

private Geometry screenToWorld(Geometry geometry) {
  if (geometry != null) {
    Geometry result = new Geometry(geometry.getGeometryType(), geometry.getSrid(), geometry.getPrecision());
    if (geometry.getGeometries() != null) {
      Geometry[] transformed = new Geometry[geometry.getGeometries().length];
      for (int i = 0; i < geometry.getGeometries().length; i++) {
        transformed[i] = screenToWorld(geometry.getGeometries()[i]);
      }
      result.setGeometries(transformed);
    }
    if (geometry.getCoordinates() != null) {
      Coordinate[] transformed = new Coordinate[geometry.getCoordinates().length];
      for (int i = 0; i < geometry.getCoordinates().length; i++) {
        transformed[i] = screenToWorld(geometry.getCoordinates()[i]);
      }
      result.setCoordinates(transformed);
    }
    return result;
  }
  throw new IllegalArgumentException("Cannot transform null geometry.");
}

代码示例来源:origin: org.geomajas/geomajas-gwt-client-impl

private Geometry worldToScreen(Geometry geometry) {
  if (geometry != null) {
    Geometry result = new Geometry(geometry.getGeometryType(), geometry.getSrid(), geometry.getPrecision());
    if (geometry.getGeometries() != null) {
      Geometry[] transformed = new Geometry[geometry.getGeometries().length];
      for (int i = 0; i < geometry.getGeometries().length; i++) {
        transformed[i] = worldToScreen(geometry.getGeometries()[i]);
      }
      result.setGeometries(transformed);
    }
    if (geometry.getCoordinates() != null) {
      Coordinate[] transformed = new Coordinate[geometry.getCoordinates().length];
      for (int i = 0; i < geometry.getCoordinates().length; i++) {
        transformed[i] = worldToScreen(geometry.getCoordinates()[i]);
      }
      result.setCoordinates(transformed);
    }
    return result;
  }
  throw new IllegalArgumentException("Cannot transform null geometry.");
}

代码示例来源:origin: org.geomajas.plugin/geomajas-plugin-editing-puregwt

private void drawPolygon(GeometryIndex parentIndex) throws GeometryIndexNotFoundException {
  Geometry geometry = editService.getGeometry();
  if (parentIndex != null) {
    geometry = editService.getIndexService().getGeometry(editService.getGeometry(), parentIndex);
  }
  if (geometry.getGeometries() != null) {
    // First of all we check if the background needs to be drawn:
    if (styleProvider.getBackgroundStyle() != null && styleProvider.getBackgroundStyle().getFillOpacity() > 0) {
      drawIndex(parentIndex);
    }
    // Than, we draw all LinearRings one by one:
    for (int i = 0; i < geometry.getGeometries().length; i++) {
      GeometryIndex index = editService.getIndexService().addChildren(parentIndex,
          GeometryIndexType.TYPE_GEOMETRY, i);
      drawLinearRing(index);
    }
  }
}

代码示例来源:origin: org.geomajas/geomajas-client-gwt2-example-jar

private void transformInplace(Geometry geometry, Matrix matrix) {
  if (geometry.getGeometries() != null) {
    for (Geometry g : geometry.getGeometries()) {
      transformInplace(g, matrix);
    }
  } else if (geometry.getCoordinates() != null) {
    for (Coordinate c : geometry.getCoordinates()) {
      double x = c.getX() * matrix.getXx() + c.getY() * matrix.getXy() + matrix.getDx();
      double y = c.getX() * matrix.getYx() + c.getY() * matrix.getYy() + matrix.getDy();
      c.setX(x);
      c.setY(y);
    }
  }
}

代码示例来源:origin: org.geomajas.plugin/geomajas-client-gwt2-plugin-editing-example-jar

@UiHandler("addRingBtn")
protected void onAddRingButtonClicked(ClickEvent event) {
  // Set the editing service in "INSERTING" mode. Make sure it starts inserting in the correct index.
  try {
    // Add an empty LinearRing to the Polygon (add it at the end):
    Geometry polygon = editService.getGeometry();
    GeometryIndex index = editService.getIndexService().create(GeometryIndexType.TYPE_GEOMETRY,
        polygon.getGeometries().length);
    index = editService.addEmptyChild(index);
    // Make sure we can start adding coordinates into the empty LinearRing:
    index = editService.getIndexService().addChildren(index, GeometryIndexType.TYPE_VERTEX, 0);
    // Set state to "inserting". The user must start clicking on the map to insert additional points:
    editService.setEditingState(GeometryEditState.INSERTING);
    // Make sure the service knows where to insert (in the empty LinearRing):
    editService.setInsertIndex(index);
  } catch (GeometryOperationFailedException e) {
    e.printStackTrace();
  }
}

代码示例来源:origin: org.geomajas.plugin/geomajas-client-gwt2-plugin-editing-example-jar

@UiHandler("addRingBtn")
protected void onAddRingButtonClicked(ClickEvent event) {
  // Set the editing service in "INSERTING" mode. Make sure it starts inserting in the correct index.
  try {
    // Add an empty LinearRing to the Polygon.
    Geometry polygon = editService.getGeometry();
    GeometryIndex index = editService.getIndexService().create(GeometryIndexType.TYPE_GEOMETRY,
        polygon.getGeometries().length);
    index = editService.addEmptyChild(index);
    // Make sure we can start adding coordinates into the empty LinearRing:
    index = editService.getIndexService().addChildren(index, GeometryIndexType.TYPE_VERTEX, 0);
    // Set state to "inserting". The user must start clicking on the map to insert additional points:
    editService.setEditingState(GeometryEditState.INSERTING);
    // Make sure the service knows where to insert (in the empty LinearRing):
    editService.setInsertIndex(index);
  } catch (GeometryOperationFailedException e) {
    e.printStackTrace();
  }
}

代码示例来源:origin: org.geomajas.plugin/geomajas-client-gwt2-plugin-editing-example-jar

@UiHandler("addRingBtn")
protected void onAddRingButtonClicked(ClickEvent event) {
  // Set the editing service in "INSERTING" mode. Make sure it starts inserting in the correct index.
  try {
    // Add an empty LinearRing to the Polygon.
    Geometry polygon = editService.getGeometry();
    GeometryIndex index = editService.getIndexService().create(GeometryIndexType.TYPE_GEOMETRY,
        polygon.getGeometries().length);
    index = editService.addEmptyChild(index);
    // Make sure we can start adding coordinates into the empty LinearRing:
    index = editService.getIndexService().addChildren(index, GeometryIndexType.TYPE_VERTEX, 0);
    // Set state to "inserting". The user must start clicking on the map to insert additional points:
    editService.setEditingState(GeometryEditState.INSERTING);
    // Make sure the service knows where to insert (in the empty LinearRing):
    editService.setInsertIndex(index);
  } catch (GeometryOperationFailedException e) {
    e.printStackTrace();
  }
}

代码示例来源:origin: org.geomajas/geomajas-client-gwt2-impl

@Override
public void paint(Canvas canvas, Matrix matrix) {
  if (Geometry.POLYGON.equals(geometry.getGeometryType())) {
    canvas.getContext2d().save();
    canvas.getContext2d().setFillStyle(fillStyle);
    canvas.getContext2d().setStrokeStyle(strokeStyle);
    canvas.getContext2d().setLineWidth(strokeWidthPixels / matrix.getXx());
    canvas.getContext2d().beginPath();
    for (Geometry ring : geometry.getGeometries()) {
      Coordinate[] coords = ring.getCoordinates();
      canvas.getContext2d().moveTo(coords[0].getX(), coords[0].getY());
      for (int i = 1; i < coords.length - 1; i++) {
        canvas.getContext2d().lineTo(coords[i].getX(), coords[i].getY());
      }
    }
    canvas.getContext2d().closePath();
    canvas.getContext2d().fill();
    canvas.getContext2d().stroke();
    canvas.getContext2d().restore();
  }
}

代码示例来源:origin: org.geomajas/geomajas-gwt-client-impl

@Override
public void paint(Canvas canvas, Matrix matrix) {
  if (Geometry.POLYGON.equals(geometry.getGeometryType())) {
    canvas.getContext2d().save();
    canvas.getContext2d().setFillStyle(fillStyle);
    canvas.getContext2d().setStrokeStyle(strokeStyle);
    canvas.getContext2d().setLineWidth(strokeWidthPixels / matrix.getXx());
    canvas.getContext2d().beginPath();
    for (Geometry ring : geometry.getGeometries()) {
      Coordinate[] coords = ring.getCoordinates();
      canvas.getContext2d().moveTo(coords[0].getX(), coords[0].getY());
      for (int i = 1; i < coords.length - 1; i++) {
        canvas.getContext2d().lineTo(coords[i].getX(), coords[i].getY());
      }
    }
    canvas.getContext2d().closePath();
    canvas.getContext2d().fill();
    canvas.getContext2d().stroke();
    canvas.getContext2d().restore();
  }
}

相关文章