planetiler/planetiler-core/src/main/java/com/onthegomap/planetiler/geo/GeometryType.java

53 wiersze
1.5 KiB
Java
Czysty Zwykły widok Historia

package com.onthegomap.planetiler.geo;
2021-05-25 10:05:41 +00:00
import org.locationtech.jts.geom.Geometry;
import org.locationtech.jts.geom.Lineal;
import org.locationtech.jts.geom.Polygonal;
import org.locationtech.jts.geom.Puntal;
2021-09-10 00:46:20 +00:00
import vector_tile.VectorTileProto;
2021-05-25 10:05:41 +00:00
public enum GeometryType {
2021-10-20 01:57:47 +00:00
UNKNOWN(VectorTileProto.Tile.GeomType.UNKNOWN, 0),
POINT(VectorTileProto.Tile.GeomType.POINT, 1),
LINE(VectorTileProto.Tile.GeomType.LINESTRING, 2),
POLYGON(VectorTileProto.Tile.GeomType.POLYGON, 4);
2021-05-25 10:05:41 +00:00
2021-09-10 00:46:20 +00:00
private final VectorTileProto.Tile.GeomType protobufType;
2022-02-24 01:45:56 +00:00
private final int minPoints;
2021-05-25 10:05:41 +00:00
2021-10-20 01:57:47 +00:00
GeometryType(VectorTileProto.Tile.GeomType protobufType, int minPoints) {
2021-05-25 10:05:41 +00:00
this.protobufType = protobufType;
2021-10-20 01:57:47 +00:00
this.minPoints = minPoints;
2021-05-25 10:05:41 +00:00
}
public static GeometryType valueOf(Geometry geom) {
return geom instanceof Puntal ? POINT : geom instanceof Lineal ? LINE : geom instanceof Polygonal ? POLYGON :
UNKNOWN;
2021-05-25 10:05:41 +00:00
}
2021-09-10 00:46:20 +00:00
public static GeometryType valueOf(VectorTileProto.Tile.GeomType geomType) {
2021-05-25 10:05:41 +00:00
return switch (geomType) {
case POINT -> POINT;
case LINESTRING -> LINE;
case POLYGON -> POLYGON;
default -> UNKNOWN;
};
}
public static GeometryType valueOf(byte val) {
2021-09-10 00:46:20 +00:00
return valueOf(VectorTileProto.Tile.GeomType.forNumber(val));
2021-05-25 10:05:41 +00:00
}
public byte asByte() {
return (byte) protobufType.getNumber();
}
2021-09-10 00:46:20 +00:00
public VectorTileProto.Tile.GeomType asProtobufType() {
2021-05-25 10:05:41 +00:00
return protobufType;
}
2021-10-20 01:57:47 +00:00
public int minPoints() {
return minPoints;
}
2021-05-25 10:05:41 +00:00
}