Skip to content

Commit

Permalink
move around methods
Browse files Browse the repository at this point in the history
  • Loading branch information
msbarry committed Nov 15, 2023
1 parent 762c796 commit 1316a42
Showing 1 changed file with 30 additions and 24 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,28 @@ public Feature innermostPoint(String layer) {
return innermostPoint(layer, 0.1);
}

/** Returns the minimum zoom level at which this feature is at least {@code pixelSize} pixels large. */
public int getMinZoomForPixelSize(double pixelSize) {
try {
return GeoUtils.minZoomForPixelSize(source.size(), pixelSize);
} catch (GeometryException e) {
e.log(stats, "min_zoom_for_size_failure", "Error getting min zoom for size from geometry " + source.id());
return config.maxzoom();
}
}


/** Returns the actual pixel size of the source feature at {@code zoom} (length if line, sqrt(area) if polygon). */
public double getPixelSizeAtZoom(int zoom) {
try {
return source.size() * (256 << zoom);
} catch (GeometryException e) {
e.log(stats, "source_feature_pixel_size_at_zoom_failure",
"Error getting source feature pixel size at zoom from geometry " + source.id());
return 0;
}
}

/**
* Creates new feature collector instances for each source feature that we encounter.
*/
Expand Down Expand Up @@ -757,20 +779,20 @@ public Feature putAttrs(Map<String, Object> attrs) {
}

/**
* Sets a special attribute key that the renderer will use to store the number of points in the simplified geometry
* Returns the attribute key that the renderer should use to store the number of points in the simplified geometry
* before slicing it into tiles.
*/
public Feature setNumPointsAttr(String numPointsAttr) {
this.numPointsAttr = numPointsAttr;
return this;
public String getNumPointsAttr() {
return numPointsAttr;
}

/**
* Returns the attribute key that the renderer should use to store the number of points in the simplified geometry
* Sets a special attribute key that the renderer will use to store the number of points in the simplified geometry
* before slicing it into tiles.
*/
public String getNumPointsAttr() {
return numPointsAttr;
public Feature setNumPointsAttr(String numPointsAttr) {
this.numPointsAttr = numPointsAttr;
return this;
}

@Override
Expand All @@ -784,23 +806,7 @@ public String toString() {

/** Returns the actual pixel size of the source feature at {@code zoom} (length if line, sqrt(area) if polygon). */
public double getSourceFeaturePixelSizeAtZoom(int zoom) {
try {
return source.size() * (256 << zoom);
} catch (GeometryException e) {
e.log(stats, "source_feature_pixel_size_at_zoom_failure",
"Error getting source feature pixel size at zoom from geometry " + source.id());
return 0;
}
}

/** Returns the minimum zoom level at which this feature is at least {@code pixelSize} pixels large. */
public int getMinZoomForPixelSize(double pixelSize) {
try {
return GeoUtils.minZoomForPixelSize(source.size(), pixelSize);
} catch (GeometryException e) {
e.log(stats, "min_zoom_for_size_failure", "Error getting min zoom for size from geometry " + source.id());
return config.maxzoom();
}
return getPixelSizeAtZoom(zoom);
}
}
}

0 comments on commit 1316a42

Please sign in to comment.