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

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

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

Geometry.setCoordinates介绍

暂无

代码示例

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

@UiHandler("editBtn")
protected void onEditButtonClicked(ClickEvent event) {
  // Create a point geometry in the center of the map:
  Geometry point = new Geometry(Geometry.POINT, 0, -1);
  point.setCoordinates(new Coordinate[] { mapPresenter.getViewPort().getPosition() });
  // Now start editing it:
  editService.start(point);
}

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

/**
 * Search for features at a certain location.
 * 
 * @param location
 *            The location to check.
 * @param isShift
 *            Is the shift button pressed down?
 */
private void searchAtLocation(Coordinate location, boolean isShift) {
  Geometry point = new Geometry(Geometry.POINT, 0, -1);
  point.setCoordinates(new Coordinate[] { location });
  mapPresenter.getFeatureService().search(point, pixelsToUnits(pixelTolerance), QueryType.INTERSECTS,
      searchLayerType, -1, new SelectionCallback(isShift, false));
}

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

dto.setCoordinates(convertCoordinates(geometry));
} else if (geometry instanceof LinearRing) {
  dto.setCoordinates(convertCoordinates(geometry));
} else if (geometry instanceof LineString) {
  dto.setCoordinates(convertCoordinates(geometry));
} else if (geometry instanceof Polygon) {
  Polygon polygon = (Polygon) geometry;

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

@UiHandler("pathBtn")
public void onPathBtnClicked(ClickEvent event) {
  Geometry geometry = new Geometry(Geometry.POLYGON, 0, 0);
  Geometry shell = new Geometry(Geometry.LINEAR_RING, 0, 0);
  shell.setCoordinates(new Coordinate[] { new Coordinate(120, 160), new Coordinate(220, 160),
      new Coordinate(220, 260), new Coordinate(120, 260), new Coordinate(120, 160) });
  Geometry hole = new Geometry(Geometry.LINEAR_RING, 0, 0);
  hole.setCoordinates(new Coordinate[] { new Coordinate(140, 180), new Coordinate(190, 180),
      new Coordinate(190, 230), new Coordinate(140, 230), new Coordinate(140, 180) });
  geometry.setGeometries(new Geometry[] { shell, hole });
  Shape shape = (Shape) GeomajasImpl.getInstance().getGfxUtil().toShape(geometry);
  shape.setFillColor("#0066AA");
  shape.setFillOpacity(0.4);
  shape.setStrokeColor("#004499");
  container.add(shape);
}

代码示例来源: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-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/geomajas-gwt-client-impl

@Override
public void onUp(HumanInputEvent<?> event) {
  // Assure dragging or clicking started inside this widget
  if (dragging) {
    shift |= event.isShiftKeyDown(); // shift is used when depressed either at beginning or end
    updateCircle(event);
    
    Geometry geometry = new Geometry(Geometry.POINT, 0, -1);
    Coordinate[] coordinates = new Coordinate[]{new Coordinate(circle.getUserX(), circle.getUserY())};
    geometry.setCoordinates(coordinates);
    ViewPort viewPort = mapPresenter.getViewPort();
    execute(viewPort.transform(geometry, RenderSpace.SCREEN, RenderSpace.WORLD), 
        circle.getRadius() / viewPort.getScale());
    stopDragging();
    dragging = false;
  }
}

代码示例来源: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-client-gwt2-example-jar

@UiHandler("polyBtn")
public void onPolyBtnClicked(ClickEvent event) {
  if (polygonContainer != null) {
    polygonContainer.clear();
    List<CanvasShape> shapes = new ArrayList<CanvasShape>();
    double factor = Math.pow(count, -0.5);
    for (int i = 0; i < count; i++) {
      double x1 = (Random.nextDouble() - 0.5) * (TOTAL_SIZE - SHAPE_SIZE * factor);
      double y1 = (Random.nextDouble() - 0.5) * (TOTAL_SIZE - SHAPE_SIZE * factor);
      double x2 = x1 + (Random.nextDouble() - 0.5) * SHAPE_SIZE * factor;
      double y2 = y1 + (Random.nextDouble() - 0.5) * SHAPE_SIZE * factor;
      double x3 = x1 + (Random.nextDouble() - 0.5) * SHAPE_SIZE * factor;
      double y3 = y1 + (Random.nextDouble() - 0.5) * SHAPE_SIZE * factor;
      Coordinate[] coords = new Coordinate[] { new Coordinate(x1, y1), new Coordinate(x2, y2),
          new Coordinate(x3, y3), new Coordinate(x1, y1) };
      Geometry ring = new Geometry(Geometry.LINEAR_RING, 0, 5);
      ring.setCoordinates(coords);
      Geometry poly = new Geometry(Geometry.POLYGON, 0, 5);
      poly.setGeometries(new Geometry[] { ring });
      CanvasPath path = new CanvasPath(poly);
      path.setFillStyle(getRandomRGB(0.5));
      path.setStrokeStyle(getRandomRGB(1));
      shapes.add(path);
    }
    polygonContainer.addAll(shapes);
    polygonContainer.repaint();
  }
}

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

@Override
public void onUp(HumanInputEvent<?> event) {
  // Assure dragging or clicking started inside this widget
  if (dragging) {
    shift |= event.isShiftKeyDown(); // shift is used when depressed either at beginning or end
    updateCircle(event);
    
    Geometry geometry = new Geometry(Geometry.POINT, 0, -1);
    Coordinate[] coordinates = new Coordinate[]{new Coordinate(circle.getUserX(), circle.getUserY())};
    geometry.setCoordinates(coordinates);
    ViewPort viewPort = mapPresenter.getViewPort();
    execute(viewPort.getTransformationService().transform(geometry, RenderSpace.SCREEN, RenderSpace.WORLD), 
        circle.getRadius() * viewPort.getResolution());
    stopDragging();
    dragging = false;
  }
}

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

private static void parseSimple(GeometryType type, Geometry geometry, JSONArray array) {
  Coordinate[] coords;
  switch (type) {
    case POINT:
      coords = new Coordinate[1];
      coords[0] = new Coordinate();
      coords[0].setX(array.get(0).isNumber().doubleValue());
      coords[0].setY(array.get(1).isNumber().doubleValue());
      geometry.setCoordinates(coords);
      break;
    case LINEARRING:
    case LINESTRING:
      coords = new Coordinate[array.size()];
      for (int i = 0; i < coords.length; i++) {
        coords[i] = new Coordinate();
        coords[i].setX(array.get(i).isArray().get(0).isNumber().doubleValue());
        coords[i].setY(array.get(i).isArray().get(1).isNumber().doubleValue());
      }
      geometry.setCoordinates(coords);
      break;
    default:
      break;
  }
}

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

@UiHandler("editBtn")
protected void onEditButtonClicked(ClickEvent event) {
  // Create a point geometry in the center of the map:
  Geometry lineString = new Geometry(Geometry.LINE_STRING, 0, -1);
  Bbox bounds = mapPresenter.getViewPort().getBounds();
  double x1 = bounds.getX() + bounds.getWidth() / 4;
  double x2 = bounds.getMaxX() - bounds.getWidth() / 4;
  double y1 = bounds.getY() + bounds.getHeight() / 4;
  double y2 = bounds.getMaxY() - bounds.getHeight() / 4;
  lineString.setCoordinates(new Coordinate[] { new Coordinate(x1, y1), new Coordinate(x2, y1),
      new Coordinate(x2, y2), new Coordinate(x1, y2) });
  // Now start editing it:
  editService.start(lineString);
}

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

@UiHandler("editBtn")
protected void onEditButtonClicked(ClickEvent event) {
  // Create a point geometry in the center of the map:
  Geometry ring = new Geometry(Geometry.LINEAR_RING, 0, -1);
  Bbox bounds = mapPresenter.getViewPort().getBounds();
  double x1 = bounds.getX() + bounds.getWidth() / 4;
  double x2 = bounds.getMaxX() - bounds.getWidth() / 4;
  double y1 = bounds.getY() + bounds.getHeight() / 4;
  double y2 = bounds.getMaxY() - bounds.getHeight() / 4;
  ring.setCoordinates(new Coordinate[] { new Coordinate(x1, y1), new Coordinate(x2, y1), new Coordinate(x2, y2),
      new Coordinate(x1, y2), new Coordinate(x1, y1) });
  Geometry polygon = new Geometry(Geometry.POLYGON, 0, 5);
  polygon.setGeometries(new Geometry[] { ring });
  // Now start editing it:
  editService.start(polygon);
}

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

@UiHandler("editBtn")
protected void onEditButtonClicked(ClickEvent event) {
  // Create a point geometry in the center of the map:
  Geometry ring = new Geometry(Geometry.LINEAR_RING, 0, -1);
  Bbox bounds = mapPresenter.getViewPort().getBounds();
  double x1 = bounds.getX() + bounds.getWidth() / 4;
  double x2 = bounds.getMaxX() - bounds.getWidth() / 4;
  double y1 = bounds.getY() + bounds.getHeight() / 4;
  double y2 = bounds.getMaxY() - bounds.getHeight() / 4;
  ring.setCoordinates(new Coordinate[] { new Coordinate(x1, y1), new Coordinate(x2, y1), new Coordinate(x2, y2),
      new Coordinate(x1, y2), new Coordinate(x1, y1) });
  Geometry polygon = new Geometry(Geometry.POLYGON, 0, 5);
  polygon.setGeometries(new Geometry[] { ring });
  // Now start editing it:
  editService.start(polygon);
}

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

@UiHandler("editBtn")
protected void onEditButtonClicked(ClickEvent event) {
  validationEventLayout.clear();
  // Create a point geometry in the center of the map:
  Geometry ring = new Geometry(Geometry.LINEAR_RING, 0, -1);
  Bbox bounds = mapPresenter.getViewPort().getBounds();
  double x1 = bounds.getX() + bounds.getWidth() / 4;
  double x2 = bounds.getMaxX() - bounds.getWidth() / 4;
  double y1 = bounds.getY() + bounds.getHeight() / 4;
  double y2 = bounds.getMaxY() - bounds.getHeight() / 4;
  ring.setCoordinates(new Coordinate[] { new Coordinate(x1, y1), new Coordinate(x2, y1), new Coordinate(x2, y2),
      new Coordinate(x1, y2), new Coordinate(x1, y1) });
  Geometry polygon = new Geometry(Geometry.POLYGON, 0, 5);
  polygon.setGeometries(new Geometry[] { ring });
  // Enable default validation
  editService.setDefaultValidation(true);
  // Now start editing it:
  editService.start(polygon);
}

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

double y2 = bounds.getMaxY() - bounds.getHeight() / 4;
ring.setCoordinates(new Coordinate[] { new Coordinate(x1, y1), new Coordinate(x2, y1), new Coordinate(x2, y2),
    new Coordinate(x1, y2), new Coordinate(x1, y1) });
Geometry polygon = new Geometry(Geometry.POLYGON, 0, 5);

相关文章