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

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

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

Geometry.getGeometryType介绍

暂无

代码示例

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

public void setGeometry(Geometry geometry) {
  closed = Geometry.POLYGON.equals(geometry.getGeometryType())
      || Geometry.MULTI_POLYGON.equals(geometry.getGeometryType());
  skipTransform = true;
  try {
    if (Geometry.LINE_STRING.equals(geometry.getGeometryType())) {
      setLineString(geometry);
    } else if (Geometry.LINEAR_RING.equals(geometry.getGeometryType())) {
      setLinearRing(geometry);
    } else if (Geometry.POLYGON.equals(geometry.getGeometryType())) {
      setPolygon(geometry);
    } else if (Geometry.MULTI_LINE_STRING.equals(geometry.getGeometryType())) {
      setMultiLineString(geometry);
    } else if (Geometry.MULTI_POLYGON.equals(geometry.getGeometryType())) {
      setMultiPolygon(geometry);
    } else {
      throw new IllegalArgumentException("Unsupported geometry " + geometry.getGeometryType());
    }
  } finally {
    skipTransform = false;
    drawTransformed();
  }
}

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

private void draw() throws GeometryIndexNotFoundException {
  if (Geometry.POINT.equals(editService.getGeometry().getGeometryType())) {
    drawPoint(null);
  } else if (Geometry.LINE_STRING.equals(editService.getGeometry().getGeometryType())
      || Geometry.LINEAR_RING.equals(editService.getGeometry().getGeometryType())) {
    drawLineString(null);
  } else if (Geometry.POLYGON.equals(editService.getGeometry().getGeometryType())) {
    drawPolygon(null);
  }
}

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

public void setGeometry(Geometry geometry) {
  setClosed(
      Geometry.POLYGON.equals(geometry.getGeometryType())
      || Geometry.MULTI_POLYGON.equals(geometry.getGeometryType())
      || Geometry.LINEAR_RING.equals(geometry.getGeometryType()));
  skipTransform = true;
  try {
    if (Geometry.LINE_STRING.equals(geometry.getGeometryType())) {
      setLineString(geometry);
    } else if (Geometry.LINEAR_RING.equals(geometry.getGeometryType())) {
      setLinearRing(geometry);
    } else if (Geometry.POLYGON.equals(geometry.getGeometryType())) {
      setPolygon(geometry);
    } else if (Geometry.MULTI_LINE_STRING.equals(geometry.getGeometryType())) {
      setMultiLineString(geometry);
    } else if (Geometry.MULTI_POLYGON.equals(geometry.getGeometryType())) {
      setMultiPolygon(geometry);
    } else {
      throw new IllegalArgumentException("Unsupported geometry " + geometry.getGeometryType());
    }
  } finally {
    skipTransform = false;
    drawTransformed();
  }
}

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

public VectorObject toShape(Geometry geometry) {
  if (geometry != null) {
    if (GeometryService.getNumPoints(geometry) == 0) {
      return null;
    }
    if (Geometry.POINT.equals(geometry.getGeometryType())) {
      return toShapePoint(geometry);
    } else if (Geometry.MULTI_POINT.equals(geometry.getGeometryType())) {
      return toShapeMultiPoint(geometry);
    } else {
      return new GeometryPath(geometry);
    }
  }
  return null;
}

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

@Override
public VectorObject toShape(Geometry geometry) {
  if (geometry != null) {
    if (GeometryService.getNumPoints(geometry) == 0) {
      return null;
    }
    if (Geometry.POINT.equals(geometry.getGeometryType())) {
      return toShapePoint(geometry);
    } else if (Geometry.MULTI_POINT.equals(geometry.getGeometryType())) {
      return toShapeMultiPoint(geometry);
    } else {
      return new GeometryPath(geometry);
    }
  }
  return null;
}

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

private VectorObject scaleAndStyle(Geometry geom) {
  Matrix scale = new Matrix(1000000, 0, 0, 1000000, 0, 0);
  GfxUtil util = GeomajasImpl.getInstance().getGfxUtil();
  VectorObject shape = util.toShape(transform(geom, scale));
  util.applyStroke(shape, "#CC9900", 0.8, 1, "2 5");
  util.applyFill(shape, "#CC9900", geom.getGeometryType().endsWith("String") ? 0f : 0.5f);
  return shape;
}

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

if (!indicesToUpdate.containsKey(index)) {
  indicesToUpdate.put(index, false);
  if (!Geometry.POINT.equals(editService.getGeometry().getGeometryType())
      && !Geometry.MULTI_POINT.equals(editService.getGeometry().getGeometryType())) {
    try {
      List<GeometryIndex> neighbors = null;
if (event.getGeometry().getGeometryType().equals(Geometry.POLYGON)) {
  update(null, false);
} else if (event.getGeometry().getGeometryType().equals(Geometry.MULTI_POLYGON)
    && event.getGeometry().getGeometries() != null) {
  for (int i = 0; i < event.getGeometry().getGeometries().length; i++) {

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

com.vividsolutions.jts.geom.Geometry jts;
String geometryType = geometry.getGeometryType();
if (GeometryService.isEmpty(geometry)) {
  jts = createEmpty(factory, geometryType);

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

private void render(Feature f) {
  VectorObject shape = gfxUtil.toShape(f.getGeometry());
  String type = f.getGeometry().getGeometryType();
  if (Geometry.POINT.equals(type) || Geometry.MULTI_POINT.equals(type)) {
    gfxUtil.applyStroke(shape, pointStyle.getStrokeColor(), pointStyle.getStrokeOpacity(),
        pointStyle.getStrokeWidth(), pointStyle.getDashArray());
    gfxUtil.applyFill(shape, pointStyle.getFillColor(), pointStyle.getFillOpacity());
  } else if (Geometry.LINE_STRING.equals(type) || Geometry.MULTI_LINE_STRING.equals(type)) {
    gfxUtil.applyStroke(shape, lineStyle.getStrokeColor(), lineStyle.getStrokeOpacity(),
        lineStyle.getStrokeWidth(), lineStyle.getDashArray());
  } else {
    gfxUtil.applyStroke(shape, ringStyle.getStrokeColor(), ringStyle.getStrokeOpacity(),
        ringStyle.getStrokeWidth(), ringStyle.getDashArray());
    gfxUtil.applyFill(shape, ringStyle.getFillColor(), ringStyle.getFillOpacity());
  }
  container.add(shape);
  shapes.put(f.getId(), shape);
}

代码示例来源: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-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-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();
  }
}

相关文章