Package org.geomajas.geometry

Examples of org.geomajas.geometry.Coordinate


    Path path = toPath((LineString) multiLineString.getGeometryN(0));
    for (int i = 1; i < multiLineString.getNumGeometries(); i++) {
      LineString lineString = (LineString) multiLineString.getGeometryN(i);
      path.moveTo((int) lineString.getCoordinate().getX(), (int) lineString.getCoordinate().getY());
      for (int j = 1; j < lineString.getNumPoints(); j++) {
        Coordinate coordinate = lineString.getCoordinateN(j);
        path.lineTo((int) coordinate.getX(), (int) coordinate.getY());
      }
    }
    return path;
  }
View Full Code Here


      Polygon polygon = (Polygon) multiPolygon.getGeometryN(g);

      LinearRing exteriorRing = polygon.getExteriorRing();
      path.moveTo((int) exteriorRing.getCoordinate().getX(), (int) exteriorRing.getCoordinate().getY());
      for (int i = 1; i < exteriorRing.getNumPoints() - 1; i++) {
        Coordinate coordinate = exteriorRing.getCoordinateN(i);
        path.lineTo((int) coordinate.getX(), (int) coordinate.getY());
      }
      path.close();

      for (int i = 0; i < polygon.getNumInteriorRing(); i++) {
        LinearRing interiorRing = polygon.getInteriorRingN(i);
        path.moveTo((int) interiorRing.getCoordinate().getX(), (int) interiorRing.getCoordinate().getY());
        for (int j = 1; j < interiorRing.getNumPoints() - 1; j++) {
          Coordinate coordinate = interiorRing.getCoordinateN(j);
          path.lineTo((int) coordinate.getX(), (int) coordinate.getY());
        }
        path.close();
      }
    }
    return path;
View Full Code Here

   */
  public Coordinate snap(Coordinate coordinate) {
    if (rules == null || mapModel == null) {
      return coordinate;
    }
    Coordinate snappedCoordinate = coordinate;
    double snappedDistance = Double.MAX_VALUE;

    for (int i = 0; i < rules.size(); i++) {
      SnappingRuleInfo rule = rules.get(i);

View Full Code Here

   *            coordinate.
   * @return Returns the eventual snapped coordinate, or null if no snapping occurred.
   */
  Coordinate getSnappingPoint(Coordinate original, double threshold) {
    minimumDistance = Double.MAX_VALUE;
    Coordinate snappingPoint = null;
    double currThreshold = threshold;

    for (Coordinate[] coordinateArray : coordinates) {
      for (int j = 1; j < coordinateArray.length; j++) {
        LineSegment line = new LineSegment(coordinateArray[j], coordinateArray[j - 1]);
View Full Code Here

      if (rule.getType() == SnappingType.CLOSEST_ENDPOINT) {
        algorithm = new ClosestPointAlgorithm(geometries, rule.getDistance());
      } else {
        algorithm = new NearestAlgorithm(geometries, rule.getDistance());
      }
      Coordinate snapPointIfFound = algorithm.getSnappingPoint(coordinate, distance);
      if (snapPointIfFound != null) {
        snappedCoordinate = snapPointIfFound;
        distance = algorithm.getMinimumDistance();
      }
    }
View Full Code Here

      }
      return false;
    } else if (geometry instanceof LineString) {
      return touchesLineString((LineString) geometry, coordinate);
    } else if (geometry instanceof Point) {
      Coordinate c = geometry.getCoordinates()[0];
      Vector2D v1 = new Vector2D(c.getX(), c.getY());
      Vector2D v2 = new Vector2D(coordinate.getX(), coordinate.getY());
      return (v1.distance(v2) < ZERO);
    }
    return false;
  }
View Full Code Here

   * @private
   */
  private static boolean isWithinRing(LinearRing linearRing, Coordinate coordinate) {
    int counter = 0;
    int num = linearRing.getNumPoints();
    Coordinate c1 = linearRing.getCoordinateN(0);
    for (int i = 1; i <= num; i++) {
      Coordinate c2 = linearRing.getCoordinateN(i % num); // this way, it should work to concatenate all ring
      // coordinate arrays of a polygon....(if they all have an equal number of coordinates)
      if (coordinate.getY() > Math.min(c1.getY(), c2.getY())) { // some checks to try and avoid the expensive
        // intersect calculation.
        if (coordinate.getY() <= Math.max(c1.getY(), c2.getY())) {
          if (coordinate.getX() <= Math.max(c1.getX(), c2.getX())) {
            if (c1.getY() != c2.getY()) {
              double xIntercept = (coordinate.getY() - c1.getY()) * (c2.getX() - c1.getX())
                  / (c2.getY() - c1.getY()) + c1.getX();
              if (c1.getX() == c2.getX() || coordinate.getX() <= xIntercept) {
                counter++;
              }
            }
          }
        }
View Full Code Here

    final String singleSelectionId = mapWidget.getMapModel().getSelectedFeature();
    if (clearSelection) {
      mapWidget.getMapModel().clearSelectedFeatures();
    }
    MapModel mapModel = mapWidget.getMapModel();
    Coordinate worldPosition = mapModel.getMapView().getWorldViewTransformer().viewToWorld(coordinate);
    GwtCommand commandRequest = new GwtCommand(SearchByLocationRequest.COMMAND);
    SearchByLocationRequest request = new SearchByLocationRequest();
    Layer<?> layer = mapModel.getSelectedLayer();
    if (priorityToSelectedLayer && layer != null && layer instanceof VectorLayer) {
      if (!layer.isShowing()) {
View Full Code Here

    return layerIds.toArray(new String[] {});
  }

  private double calculateBufferFromPixelTolerance() {
    WorldViewTransformer transformer = mapWidget.getMapModel().getMapView().getWorldViewTransformer();
    Coordinate c1 = transformer.viewToWorld(new Coordinate(0, 0));
    Coordinate c2 = transformer.viewToWorld(new Coordinate(pixelTolerance, 0));
    return Mathlib.distance(c1, c2);
  }
View Full Code Here

   * Only moving rectangle or reticle during drag.
   */
  @Override
  public void onMouseMove(MouseMoveEvent event) {
    if (dragging) {
      Coordinate current = getScreenPosition(event);
      getOverviewMap().movePov(current.getX() - previous.getX(), current.getY() - previous.getY());
      previous = current;
    }
  }
View Full Code Here

TOP

Related Classes of org.geomajas.geometry.Coordinate

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.