Package org.geomajas.geometry

Examples of org.geomajas.geometry.Coordinate


  @Autowired
  private GeoService service;

  @Test
  public void testConversion() throws Exception {
    Coordinate latlon = new Coordinate(50, 4);
    Coordinate google = GeoUtil.convertToGoogle(latlon);
    Envelope env = service.transform(new Envelope(0, 4, 0, 50), "EPSG:4326", "EPSG:900913");
    Assert.assertEquals(google.getX(), env.getMaxX(), 0.01);
    Assert.assertEquals(google.getY(), env.getMaxY(), 0.01);
  }
View Full Code Here


    jtsC5 = new com.vividsolutions.jts.geom.Coordinate(12.0, 12.0);
    jtsC6 = new com.vividsolutions.jts.geom.Coordinate(12.0, 18.0);
    jtsC7 = new com.vividsolutions.jts.geom.Coordinate(18.0, 18.0);
    jtsC8 = new com.vividsolutions.jts.geom.Coordinate(18.0, 12.0);

    dtoC1 = new Coordinate(10.0, 10.0);
    dtoC2 = new Coordinate(20.0, 10.0);
    dtoC3 = new Coordinate(20.0, 20.0);
    dtoC4 = new Coordinate(10.0, 20.0);
    dtoC5 = new Coordinate(12.0, 12.0);
    dtoC6 = new Coordinate(12.0, 18.0);
    dtoC7 = new Coordinate(18.0, 18.0);
    dtoC8 = new Coordinate(18.0, 12.0);
  }
View Full Code Here

      // combine location envelopes
      Envelope resultEnvelope = combineResultService.combine(results);
      Bbox bbox = dtoConverterService.toDto(resultEnvelope);
      response.setBbox(bbox);
      response.setCenter(new Coordinate(bbox.getX() + bbox.getWidth() / 2, bbox.getY() + bbox.getHeight() / 2));
    } else {
      List<GetLocationForStringAlternative> altList = new ArrayList<GetLocationForStringAlternative>();
      response.setAlternatives(altList);
      for (GetLocationResult[] altArr : alternatives) {
        for (GetLocationResult alt : altArr) {
          if (maxAlternatives > 0 && maxAlternatives <= altList.size()) {
            break;
          }
          GetLocationForStringAlternative one = new GetLocationForStringAlternative();

          String matchedLocation = location;
          List<String> matchedStrings = alt.getCanonicalStrings();
          if (null != matchedStrings) {
            matchedLocation = splitGeocoderStringService.combine(matchedStrings);
          }
          one.setCanonicalLocation(matchedLocation);

          // set additional info data
          one.setGeocoderName(alt.getGeocoderName());
          one.setUserData(alt.getUserData());

          // combine location envelopes
          Bbox bbox = dtoConverterService.toDto(alt.getEnvelope());
          one.setBbox(bbox);
          one.setCenter(
              new Coordinate(bbox.getX() + bbox.getWidth() / 2, bbox.getY() + bbox.getHeight() / 2));

          altList.add(one);
        }
      }
    }
View Full Code Here

   */
  public static Coordinate convertToLatLon(Coordinate coordinate) {
    double lat = (coordinate.getY() / MERCATOR_WIDTH) * 180.0;
    double lon = (coordinate.getX() / MERCATOR_WIDTH) * 180.0;
    lat = 180 / Math.PI * (2 * Math.atan(Math.exp(lat * Math.PI / 180.0)) - Math.PI / 2.0);
    return new Coordinate(lat, lon);
  }
View Full Code Here

   * @return google coordinate
   */
  public static Coordinate convertToGoogle(Coordinate coordinate) {
    double x = (coordinate.getY() / 180.0) * MERCATOR_WIDTH;
    double y = MERCATOR_WIDTH / Math.PI * Math.log(Math.tan((90.0 + coordinate.getX()) * Math.PI / 360.0));
    return new Coordinate(x, y);
  }
View Full Code Here

   * Sets the center of the map.
   * @param lat latitude of the center
   * @param lon longitude of the center
   */
  public void setCenter(double lat, double lon) {
    getMapModel().getMapView().setCenterPosition(GeoUtil.convertToGoogle(new Coordinate(lat, lon)));
  }
View Full Code Here

   * @param imageSrc src of the marker image
   * @param width width of the marker image
   * @param height height of the marker image
   */
  public void addMarker(String id, double lat, double lon, String imageSrc, int width, int height) {
    registerWorldPaintable(new Marker(id, imageSrc, GeoUtil.convertToGoogle(new Coordinate(lat, lon)), width,
        height));
  }
View Full Code Here

    obj.setFeatureIncludes(GeomajasConstant.FEATURE_INCLUDE_GEOMETRY);
    obj.setFilter("bla");
    obj.setLayerId("beans");
    obj.setPaintGeometries(true);
    obj.setPaintLabels(false);
    obj.setPanOrigin(new Coordinate(10, 20));
    obj.setRenderer("SVG");
    obj.setScale(2.5);
    NamedStyleInfo nsi = new NamedStyleInfo();
    nsi.setName("nsi");
    obj.setStyleInfo(nsi);
View Full Code Here

  public void testGetVectorTile() throws Exception {
    GetVectorTileRequest request = new GetVectorTileRequest();
    request.setCrs(CRS);
    request.setLayerId(LAYER_ID);
    request.setCode(new TileCode(0, 0, 0));
    request.setPanOrigin(new Coordinate(0, 0));
    request.setRenderer(GetVectorTileRequest.PARAM_SVG_RENDERER);
    request.setScale(1.0);
    GetVectorTileResponse response = (GetVectorTileResponse) dispatcher.execute(
        GetVectorTileRequest.COMMAND, request, null, "en");
    if (response.isError()) {
View Full Code Here

    Assert.assertNotNull(features);
    Assert.assertEquals(1, features.length);
    Assert.assertEquals("Country 3", features[0].getLabel());
    Geometry geometry = features[0].getGeometry();
    Assert.assertNotNull(geometry);
    Coordinate coor = geometry.getGeometries()[0].getGeometries()[0].getCoordinates()[0];
    Assert.assertEquals(-1, coor.getX(), DOUBLE_TOLERANCE);
    Assert.assertEquals(0, coor.getY(), DOUBLE_TOLERANCE);

    // try again using mercator
    request.setCrs("EPSG:900913");
    response = (SearchFeatureResponse) dispatcher.execute(SearchFeatureRequest.COMMAND, request, null, "en");
    if (response.isError()) {
      response.getErrors().get(0).printStackTrace();
    }
    Assert.assertFalse(response.isError());
    Assert.assertEquals(LAYER_ID, response.getLayerId());
    features = response.getFeatures();
    Assert.assertNotNull(features);
    Assert.assertEquals(1, features.length);
    Assert.assertEquals("Country 3", features[0].getLabel());
    geometry = features[0].getGeometry();
    Assert.assertNotNull(geometry);
    coor = geometry.getGeometries()[0].getCoordinates()[0];
    // remark, this value is obtained using a test run, not externally verified
    Assert.assertEquals(-111319.49079327357, coor.getX(), DOUBLE_TOLERANCE);
    Assert.assertEquals(0, coor.getY(), DOUBLE_TOLERANCE);
  }
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.