forked from elastic/elasticsearch
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactor SimpleFeatureFactory so it has no external dependencies (ela…
…stic#75232) SimpleFeatureFactory has no external dependencies now.
- Loading branch information
Showing
8 changed files
with
602 additions
and
163 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
63 changes: 0 additions & 63 deletions
63
...or-tile/src/main/java/org/elasticsearch/xpack/vectortile/feature/FeatureFactoryUtils.java
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
50 changes: 50 additions & 0 deletions
50
...tile/src/main/java/org/elasticsearch/xpack/vectortile/feature/SphericalMercatorUtils.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0; you may not use this file except in compliance with the Elastic License | ||
* 2.0. | ||
*/ | ||
|
||
package org.elasticsearch.xpack.vectortile.feature; | ||
|
||
import org.elasticsearch.geometry.Rectangle; | ||
|
||
/** | ||
* Utility functions to transforms WGS84 coordinates into spherical mercator. | ||
*/ | ||
class SphericalMercatorUtils { | ||
|
||
private static double MERCATOR_FACTOR = 20037508.34 / 180.0; | ||
|
||
/** | ||
* Transforms WGS84 longitude to a Spherical mercator longitude | ||
*/ | ||
public static double lonToSphericalMercator(double lon) { | ||
return lon * MERCATOR_FACTOR; | ||
} | ||
|
||
/** | ||
* Transforms WGS84 latitude to a Spherical mercator latitude | ||
*/ | ||
public static double latToSphericalMercator(double lat) { | ||
double y = Math.log(Math.tan((90 + lat) * Math.PI / 360)) / (Math.PI / 180); | ||
return y * MERCATOR_FACTOR; | ||
} | ||
|
||
/** | ||
* Transforms WGS84 rectangle to a Spherical mercator rectangle | ||
*/ | ||
public static Rectangle recToSphericalMercator(Rectangle r) { | ||
return new Rectangle( | ||
lonToSphericalMercator(r.getMinLon()), | ||
lonToSphericalMercator(r.getMaxLon()), | ||
latToSphericalMercator(r.getMaxLat()), | ||
latToSphericalMercator(r.getMinLat()) | ||
); | ||
|
||
} | ||
|
||
private SphericalMercatorUtils() { | ||
// no instances | ||
} | ||
} |
Oops, something went wrong.