kopia lustrzana https://github.com/onthegomap/planetiler
				
				
				
			Linting - spelling, tiny cleanups (#150)
* Linting - spelling, tiny cleanups Grammar fixes, marked one place as `final`, etc. * formattingpull/151/head
							rodzic
							
								
									96b6f200c6
								
							
						
					
					
						commit
						bc66bbd352
					
				| 
						 | 
				
			
			@ -22,7 +22,7 @@ import org.locationtech.jts.geom.Geometry;
 | 
			
		|||
 * feature.
 | 
			
		||||
 * <p>
 | 
			
		||||
 * For example to add a polygon feature for a lake and a center label point with its name:
 | 
			
		||||
 * 
 | 
			
		||||
 *
 | 
			
		||||
 * <pre>
 | 
			
		||||
 * {@code
 | 
			
		||||
 * featureCollector.polygon("water")
 | 
			
		||||
| 
						 | 
				
			
			@ -673,7 +673,7 @@ public class FeatureCollector implements Iterable<FeatureCollector.Feature> {
 | 
			
		|||
     * Inserts all key/value pairs in {@code attrs} into the set of attribute to emit on the output feature at or above
 | 
			
		||||
     * {@code minzoom}.
 | 
			
		||||
     * <p>
 | 
			
		||||
     * Replaces values that have already been set.
 | 
			
		||||
     * Replace values that have already been set.
 | 
			
		||||
     */
 | 
			
		||||
    public Feature putAttrsWithMinzoom(Map<String, Object> attrs, int minzoom) {
 | 
			
		||||
      for (var entry : attrs.entrySet()) {
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -37,7 +37,7 @@ import org.slf4j.LoggerFactory;
 | 
			
		|||
 * {@link Profile#postProcessLayerFeatures(String, int, List)} immediately before a tile is written to the output
 | 
			
		||||
 * mbtiles file.
 | 
			
		||||
 * <p>
 | 
			
		||||
 * Unlike postgis-based solutions that have a full view of all features after they are loaded into the databse, the
 | 
			
		||||
 * Unlike postgis-based solutions that have a full view of all features after they are loaded into the database, the
 | 
			
		||||
 * planetiler engine only sees a single input feature at a time while processing source features, then only has
 | 
			
		||||
 * visibility into multiple features when they are grouped into a tile immediately before emitting. This ends up being
 | 
			
		||||
 * sufficient for most real-world use-cases but to do anything more that requires a view of multiple features
 | 
			
		||||
| 
						 | 
				
			
			@ -76,8 +76,8 @@ public class FeatureMerge {
 | 
			
		|||
  }
 | 
			
		||||
 | 
			
		||||
  /**
 | 
			
		||||
   * Merges linestrings with the same attributes like {@link #mergeLineStrings(List, double, double, double)} except
 | 
			
		||||
   * with a dynamic length limit computed by {@code lengthLimitCalculator} for the attributes of each group.
 | 
			
		||||
   * Merges linestrings with the same attributes as {@link #mergeLineStrings(List, double, double, double)} except with
 | 
			
		||||
   * a dynamic length limit computed by {@code lengthLimitCalculator} for the attributes of each group.
 | 
			
		||||
   */
 | 
			
		||||
  public static List<VectorTile.Feature> mergeLineStrings(List<VectorTile.Feature> features,
 | 
			
		||||
    Function<Map<String, Object>, Double> lengthLimitCalculator, double tolerance, double buffer) {
 | 
			
		||||
| 
						 | 
				
			
			@ -200,8 +200,8 @@ public class FeatureMerge {
 | 
			
		|||
  }
 | 
			
		||||
 | 
			
		||||
  /**
 | 
			
		||||
   * Combines polygons with the same set of attributes within {@code minDist} from eachother, expanding then contracting
 | 
			
		||||
   * the merged geometry by {@code buffer} to combine polygons that are almost touching.
 | 
			
		||||
   * Combines polygons with the same set of attributes within {@code minDist} from each other, expanding then
 | 
			
		||||
   * contracting the merged geometry by {@code buffer} to combine polygons that are almost touching.
 | 
			
		||||
   * <p>
 | 
			
		||||
   * Ignores any non-polygons and passes them through to the output unaltered.
 | 
			
		||||
   * <p>
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -349,7 +349,7 @@ public class Planetiler {
 | 
			
		|||
   * the value of the {@code wikidata_cache} argument) before processing any sources.
 | 
			
		||||
   * <p>
 | 
			
		||||
   * As long as {@code use_wikidata} is not set to false, then previously-downloaded wikidata translations will be
 | 
			
		||||
   * loaded from the cache file so you can run with {@code fetch_wikidata=true} once, then without it each subsequent
 | 
			
		||||
   * loaded from the cache file, so you can run with {@code fetch_wikidata=true} once, then without it each subsequent
 | 
			
		||||
   * run to only download translations once.
 | 
			
		||||
   *
 | 
			
		||||
   * @param defaultWikidataCache Path to store downloaded wikidata name translations to, and to read them from on
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -5,7 +5,7 @@ import java.util.function.Supplier;
 | 
			
		|||
 | 
			
		||||
/**
 | 
			
		||||
 * A {@link Supplier} that returns {@code null} when there are no elements left, with an {@link Iterable} view to
 | 
			
		||||
 * support for each loops.
 | 
			
		||||
 * support for each loop.
 | 
			
		||||
 *
 | 
			
		||||
 * @param <T> Type of element returned
 | 
			
		||||
 */
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -114,7 +114,7 @@ public interface LongLongMap extends Closeable, MemoryEstimator.HasEstimate, Dis
 | 
			
		|||
    return result;
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  /** Which long long map implementation to use. */
 | 
			
		||||
  /** Which long map implementation to use. */
 | 
			
		||||
  enum Type {
 | 
			
		||||
    /** Ignore writes and throw an exception on reads. */
 | 
			
		||||
    NOOP("noop"),
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -22,7 +22,7 @@ import org.slf4j.LoggerFactory;
 | 
			
		|||
 */
 | 
			
		||||
public interface LongLongMultimap extends MemoryEstimator.HasEstimate, DiskBacked, AutoCloseable {
 | 
			
		||||
 | 
			
		||||
  /** Returns a {@link Noop} implementation that does nothin on put and throws an exception if you try to get. */
 | 
			
		||||
  /** Returns a {@link Noop} implementation that does nothing on put and throws an exception if you try to get. */
 | 
			
		||||
  static Noop noop() {
 | 
			
		||||
    return new Noop();
 | 
			
		||||
  }
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -310,7 +310,7 @@ public class Arguments {
 | 
			
		|||
  /**
 | 
			
		||||
   * Returns an argument as long.
 | 
			
		||||
   *
 | 
			
		||||
   * @throws NumberFormatException if the argument cannot be parsed as an long
 | 
			
		||||
   * @throws NumberFormatException if the argument cannot be parsed as a long
 | 
			
		||||
   */
 | 
			
		||||
  public long getLong(String key, String description, long defaultValue) {
 | 
			
		||||
    String value = getArg(key, Long.toString(defaultValue));
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -35,7 +35,7 @@ import org.locationtech.jts.precision.GeometryPrecisionReducer;
 | 
			
		|||
public class GeoUtils {
 | 
			
		||||
 | 
			
		||||
  /** Rounding precision for 256x256px tiles encoded using 4096 values. */
 | 
			
		||||
  public static final PrecisionModel TILE_PRECISON = new PrecisionModel(4096d / 256d);
 | 
			
		||||
  public static final PrecisionModel TILE_PRECISION = new PrecisionModel(4096d / 256d);
 | 
			
		||||
  public static final GeometryFactory JTS_FACTORY = new GeometryFactory(PackedCoordinateSequenceFactory.DOUBLE_FACTORY);
 | 
			
		||||
  public static final WKBReader WKB_READER = new WKBReader(JTS_FACTORY);
 | 
			
		||||
  public static final Geometry EMPTY_GEOMETRY = JTS_FACTORY.createGeometryCollection();
 | 
			
		||||
| 
						 | 
				
			
			@ -277,11 +277,11 @@ public class GeoUtils {
 | 
			
		|||
  }
 | 
			
		||||
 | 
			
		||||
  /**
 | 
			
		||||
   * Returns a copy of {@code geom} with coordinates rounded to {@link #TILE_PRECISON} and fixes any polygon
 | 
			
		||||
   * Returns a copy of {@code geom} with coordinates rounded to {@link #TILE_PRECISION} and fixes any polygon
 | 
			
		||||
   * self-intersections or overlaps that may have caused.
 | 
			
		||||
   */
 | 
			
		||||
  public static Geometry snapAndFixPolygon(Geometry geom) throws GeometryException {
 | 
			
		||||
    return snapAndFixPolygon(geom, TILE_PRECISON);
 | 
			
		||||
    return snapAndFixPolygon(geom, TILE_PRECISION);
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  /**
 | 
			
		||||
| 
						 | 
				
			
			@ -405,7 +405,7 @@ public class GeoUtils {
 | 
			
		|||
 | 
			
		||||
  /**
 | 
			
		||||
   * Returns {@code true} if the signed area of the triangle formed by 3 sequential points changes sign anywhere along
 | 
			
		||||
   * {@code ring}, ignoring repeated and colinear points.
 | 
			
		||||
   * {@code ring}, ignoring repeated and collinear points.
 | 
			
		||||
   */
 | 
			
		||||
  public static boolean isConvex(LinearRing ring) {
 | 
			
		||||
    CoordinateSequence seq = ring.getCoordinateSequence();
 | 
			
		||||
| 
						 | 
				
			
			@ -440,14 +440,14 @@ public class GeoUtils {
 | 
			
		|||
      double z = dx1 * dy2 - dy1 * dx2;
 | 
			
		||||
 | 
			
		||||
      // if z == 0 (with small delta to account for rounding errors) then keep skipping
 | 
			
		||||
      // points to ignore repeated or colinear points
 | 
			
		||||
      // points to ignore repeated or collinear points
 | 
			
		||||
      if (Math.abs(z) < 1e-10) {
 | 
			
		||||
        continue;
 | 
			
		||||
      }
 | 
			
		||||
 | 
			
		||||
      int s = z >= 0d ? 1 : -1;
 | 
			
		||||
      if (sign == 0) {
 | 
			
		||||
        // on the first non-repeated, non-colinear points, store sign of the area for comparison
 | 
			
		||||
        // on the first non-repeated, non-collinear points, store sign of the area for comparison
 | 
			
		||||
        sign = s;
 | 
			
		||||
      } else if (sign != s) {
 | 
			
		||||
        // the sign of this triangle has changed, not convex
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -60,12 +60,12 @@ public class MbtilesWriter {
 | 
			
		|||
  private final AtomicReference<TileCoord> lastTileWritten = new AtomicReference<>();
 | 
			
		||||
  private final MbtilesMetadata mbtilesMetadata;
 | 
			
		||||
 | 
			
		||||
  private MbtilesWriter(FeatureGroup features, Mbtiles db, PlanetilerConfig config, MbtilesMetadata mbtilesMeatadata,
 | 
			
		||||
  private MbtilesWriter(FeatureGroup features, Mbtiles db, PlanetilerConfig config, MbtilesMetadata mbtilesMetadata,
 | 
			
		||||
    Stats stats, LayerStats layerStats) {
 | 
			
		||||
    this.features = features;
 | 
			
		||||
    this.db = db;
 | 
			
		||||
    this.config = config;
 | 
			
		||||
    this.mbtilesMetadata = mbtilesMeatadata;
 | 
			
		||||
    this.mbtilesMetadata = mbtilesMetadata;
 | 
			
		||||
    this.stats = stats;
 | 
			
		||||
    this.layerStats = layerStats;
 | 
			
		||||
    tilesByZoom = IntStream.rangeClosed(0, config.maxzoom())
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -50,7 +50,7 @@ public class SimpleFeature extends SourceFeature {
 | 
			
		|||
    return new SimpleFeature(latLonGeometry, null, tags, source, sourceLayer, id, null);
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  /** Returns a new feature with no tags and a geometry specified in latitude/longitide coordinates. */
 | 
			
		||||
  /** Returns a new feature with no tags and a geometry specified in latitude/longitude coordinates. */
 | 
			
		||||
  public static SimpleFeature fromLatLonGeometry(Geometry latLonGeometry) {
 | 
			
		||||
    return new SimpleFeature(latLonGeometry, null, Map.of(), null, null, idGenerator.incrementAndGet(), null);
 | 
			
		||||
  }
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -182,7 +182,7 @@ public class OsmInputFile implements Bounds.Provider, Supplier<OsmBlockSource>,
 | 
			
		|||
   */
 | 
			
		||||
  private class LazyReader implements OsmBlockSource {
 | 
			
		||||
 | 
			
		||||
    FileChannel lazyReadChannel = openChannel();
 | 
			
		||||
    final FileChannel lazyReadChannel = openChannel();
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void forEachBlock(Consumer<Block> consumer) {
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -608,7 +608,7 @@ public class OsmReader implements Closeable, MemoryEstimator.HasEstimate {
 | 
			
		|||
  }
 | 
			
		||||
 | 
			
		||||
  /**
 | 
			
		||||
   * A source feature generated from OSM elements. Inferring the geometry can be expensive, so each sublass is
 | 
			
		||||
   * A source feature generated from OSM elements. Inferring the geometry can be expensive, so each subclass is
 | 
			
		||||
   * constructed with the inputs necessary to create the geometry, but the geometry is constructed lazily on read.
 | 
			
		||||
   */
 | 
			
		||||
  private abstract class OsmFeature extends SourceFeature {
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -279,7 +279,7 @@ public class PbfDecoder implements Iterable<OsmElement> {
 | 
			
		|||
        int valueIndex = nodes.getKeysVals(kvIndex++);
 | 
			
		||||
 | 
			
		||||
        if (tags == null) {
 | 
			
		||||
          // divide by 2 as key&value, multiple by 2 because of the better approximation
 | 
			
		||||
          // divide by 2 as key&value, multiply by 2 because of the better approximation
 | 
			
		||||
          tags = new HashMap<>(Math.max(3, 2 * (nodes.getKeysValsCount() / 2) / nodes.getKeysValsCount()));
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -220,7 +220,7 @@ public class FeatureRenderer implements Consumer<FeatureCollector.Feature> {
 | 
			
		|||
          // post-processing.  Features need to be "unscaled" in FeatureGroup after line merging,
 | 
			
		||||
          // and before emitting to output mbtiles.
 | 
			
		||||
          scale = Math.max(config.maxzoom(), 14) - zoom;
 | 
			
		||||
          // need 14 bits to represent tile coordinates (4096 * 2 for buffer * 2 for zig zag encoding)
 | 
			
		||||
          // need 14 bits to represent tile coordinates (4096 * 2 for buffer * 2 for zigzag encoding)
 | 
			
		||||
          // so cap the scale factor to avoid overflowing 32-bit integer space
 | 
			
		||||
          scale = Math.min(31 - 14, scale);
 | 
			
		||||
        }
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -122,7 +122,6 @@ public class Timers {
 | 
			
		|||
 | 
			
		||||
  /** A handle that callers can use to indicate a task has finished. */
 | 
			
		||||
  public interface Finishable {
 | 
			
		||||
 | 
			
		||||
    void stop();
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -42,7 +42,7 @@ public class ByteBufferUtil {
 | 
			
		|||
  }
 | 
			
		||||
 | 
			
		||||
  /**
 | 
			
		||||
   * Attempt to force-unmap a list of memory-mapped file segments so it can safely be deleted.
 | 
			
		||||
   * Attempt to force-unmap a list of memory-mapped file segments, so it can safely be deleted.
 | 
			
		||||
   * <p>
 | 
			
		||||
   * Can also be used to force-deallocate a direct byte buffer.
 | 
			
		||||
   *
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -138,7 +138,7 @@ public class Downloader {
 | 
			
		|||
   *
 | 
			
		||||
   * @param id     short name to use for this download when logging progress
 | 
			
		||||
   * @param url    the external resource to fetch, "aws:latest" (for the latest planet .osm.pbf), or "geofabrik:extract
 | 
			
		||||
   *               name" as a shortcut to use {@link Geofabrik#getDownloadUrl(String, PlanetilerConfig)} to lookup a
 | 
			
		||||
   *               name" as a shortcut to use {@link Geofabrik#getDownloadUrl(String, PlanetilerConfig)} to look up a
 | 
			
		||||
   *               {@code .osm.pbf} <a href="https://download.geofabrik.de/">Geofabrik</a> extract URL by partial match
 | 
			
		||||
   *               on area name
 | 
			
		||||
   * @param output where to download the file to
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -166,7 +166,7 @@ public class ResourceUsage {
 | 
			
		|||
  /** A resource with instructions for increasing. */
 | 
			
		||||
  public interface Fixable {
 | 
			
		||||
 | 
			
		||||
    /** Instructions to increase a resouce. */
 | 
			
		||||
    /** Instructions to increase a resource. */
 | 
			
		||||
    String howToFix();
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Ładowanie…
	
		Reference in New Issue