2021-12-23 10:42:24 +00:00
|
|
|
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) {
|
2022-03-09 02:08:03 +00:00
|
|
|
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
|
|
|
}
|