kopia lustrzana https://github.com/onthegomap/planetiler
48 wiersze
1.5 KiB
Java
48 wiersze
1.5 KiB
Java
package com.onthegomap.flatmap;
|
|
|
|
import com.onthegomap.flatmap.geo.GeoUtils;
|
|
import java.util.ArrayList;
|
|
import java.util.List;
|
|
import org.locationtech.jts.geom.Coordinate;
|
|
import org.locationtech.jts.geom.Geometry;
|
|
import org.locationtech.jts.geom.GeometryCollection;
|
|
import org.locationtech.jts.geom.MultiPoint;
|
|
import org.locationtech.jts.geom.MultiPolygon;
|
|
import org.locationtech.jts.geom.Point;
|
|
import org.locationtech.jts.geom.Polygon;
|
|
import org.locationtech.jts.geom.util.AffineTransformation;
|
|
|
|
public class TestUtils {
|
|
|
|
public static final AffineTransformation TRANSFORM_TO_TILE = AffineTransformation
|
|
.scaleInstance(256d / 4096d, 256d / 4096d);
|
|
|
|
public static List<Coordinate> newCoordinateList(double... coords) {
|
|
List<Coordinate> result = new ArrayList<>(coords.length / 2);
|
|
for (int i = 0; i < coords.length; i += 2) {
|
|
result.add(new Coordinate(coords[i], coords[i + 1]));
|
|
}
|
|
return result;
|
|
}
|
|
|
|
public static Polygon newPolygon(double... coords) {
|
|
return GeoUtils.gf.createPolygon(newCoordinateList(coords).toArray(new Coordinate[0]));
|
|
}
|
|
|
|
public static Point newPoint(double x, double y) {
|
|
return GeoUtils.gf.createPoint(new Coordinate(x, y));
|
|
}
|
|
|
|
public static MultiPoint newMultiPoint(Point... points) {
|
|
return GeoUtils.gf.createMultiPoint(points);
|
|
}
|
|
|
|
public static MultiPolygon newMultiPolygon(Polygon... polys) {
|
|
return GeoUtils.gf.createMultiPolygon(polys);
|
|
}
|
|
|
|
public static GeometryCollection newGeometryCollection(Geometry... geoms) {
|
|
return GeoUtils.gf.createGeometryCollection(geoms);
|
|
}
|
|
}
|