Package org.h2.util.geometry
Class EWKTUtils
- java.lang.Object
-
- org.h2.util.geometry.EWKTUtils
-
public final class EWKTUtils extends java.lang.Object
EWKT format support for GEOMETRY data type.This class provides limited support of EWKT. EWKT is based on Well-known Text Representation (WKT) from OGC 06-103r4 and includes additional PostGIS extensions. SRID support from EWKT is implemented.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private static class
EWKTUtils.EWKTSource
Helper source object for EWKT reading.static class
EWKTUtils.EWKTTarget
Converter output target that writes a EWKT.
-
Field Summary
Fields Modifier and Type Field Description private static java.lang.String[]
DIMENSION_SYSTEMS
Names of dimension systems.(package private) static java.lang.String[]
TYPES
0-based type names of geometries, subtract 1 from type code to get index in this array.
-
Constructor Summary
Constructors Modifier Constructor Description private
EWKTUtils()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description private static void
addCoordinate(EWKTUtils.EWKTSource source, GeometryUtils.Target target, int dimensionSystem, int index, int total)
private static void
addRing(java.util.ArrayList<double[]> ring, GeometryUtils.Target target)
static java.lang.String
ewkb2ewkt(byte[] ewkb)
Converts EWKB to EWKT.static java.lang.String
ewkb2ewkt(byte[] ewkb, int dimensionSystem)
Converts EWKB to EWKT.static byte[]
ewkt2ewkb(java.lang.String ewkt)
Converts EWKT to EWKB.static byte[]
ewkt2ewkb(java.lang.String ewkt, int dimensionSystem)
Converts EWKT to EWKB.static java.lang.StringBuilder
formatGeometryTypeAndDimensionSystem(java.lang.StringBuilder builder, int type)
Formats type and dimension system as a string.static int
getDimensionSystem(java.lang.String ewkt)
Reads the dimension system from EWKT.private static void
parseCollection(EWKTUtils.EWKTSource source, GeometryUtils.Target target, int type, int parentType, int dimensionSystem)
static int
parseDimensionSystem(java.lang.String s)
Parses a dimension system from the given string.static void
parseEWKT(java.lang.String ewkt, GeometryUtils.Target target)
Parses a EWKT.private static void
parseEWKT(EWKTUtils.EWKTSource source, GeometryUtils.Target target, int parentType, int dimensionSystem)
Parses a EWKB.static int
parseGeometryType(java.lang.String s)
Parses geometry type and dimension system from the given string.private static void
parseMultiPointAlternative(EWKTUtils.EWKTSource source, GeometryUtils.Target target, int dimensionSystem)
private static double[]
readCoordinate(EWKTUtils.EWKTSource source, int dimensionSystem)
private static java.util.ArrayList<double[]>
readRing(EWKTUtils.EWKTSource source, int dimensionSystem)
-
-
-
Method Detail
-
ewkb2ewkt
public static java.lang.String ewkb2ewkt(byte[] ewkb)
Converts EWKB to EWKT.- Parameters:
ewkb
- source EWKB- Returns:
- EWKT representation
-
ewkb2ewkt
public static java.lang.String ewkb2ewkt(byte[] ewkb, int dimensionSystem)
Converts EWKB to EWKT.- Parameters:
ewkb
- source EWKBdimensionSystem
- dimension system- Returns:
- EWKT representation
-
ewkt2ewkb
public static byte[] ewkt2ewkb(java.lang.String ewkt)
Converts EWKT to EWKB.- Parameters:
ewkt
- source EWKT- Returns:
- EWKB representation
-
ewkt2ewkb
public static byte[] ewkt2ewkb(java.lang.String ewkt, int dimensionSystem)
Converts EWKT to EWKB.- Parameters:
ewkt
- source EWKTdimensionSystem
- dimension system- Returns:
- EWKB representation
-
parseEWKT
public static void parseEWKT(java.lang.String ewkt, GeometryUtils.Target target)
Parses a EWKT.- Parameters:
ewkt
- source EWKTtarget
- output target
-
parseGeometryType
public static int parseGeometryType(java.lang.String s)
Parses geometry type and dimension system from the given string.- Parameters:
s
- string to parse- Returns:
- geometry type and dimension system in OGC geometry code format (type + dimensionSystem * 1000)
- Throws:
java.lang.IllegalArgumentException
- if input is not valid
-
parseDimensionSystem
public static int parseDimensionSystem(java.lang.String s)
Parses a dimension system from the given string.- Parameters:
s
- string to parse- Returns:
- dimension system, one of XYZ, XYM, or XYZM
- Throws:
java.lang.IllegalArgumentException
- if input is not valid- See Also:
GeometryUtils.DIMENSION_SYSTEM_XYZ
,GeometryUtils.DIMENSION_SYSTEM_XYM
,GeometryUtils.DIMENSION_SYSTEM_XYZM
-
formatGeometryTypeAndDimensionSystem
public static java.lang.StringBuilder formatGeometryTypeAndDimensionSystem(java.lang.StringBuilder builder, int type)
Formats type and dimension system as a string.- Parameters:
builder
- string buildertype
- OGC geometry code format (type + dimensionSystem * 1000)- Returns:
- the specified string builder
- Throws:
java.lang.IllegalArgumentException
- if type is not valid
-
parseEWKT
private static void parseEWKT(EWKTUtils.EWKTSource source, GeometryUtils.Target target, int parentType, int dimensionSystem)
Parses a EWKB.- Parameters:
source
- EWKT sourcetarget
- output targetparentType
- type of parent geometry collection, or 0 for the root geometrydimensionSystem
- dimension system of parent geometry
-
parseCollection
private static void parseCollection(EWKTUtils.EWKTSource source, GeometryUtils.Target target, int type, int parentType, int dimensionSystem)
-
parseMultiPointAlternative
private static void parseMultiPointAlternative(EWKTUtils.EWKTSource source, GeometryUtils.Target target, int dimensionSystem)
-
readRing
private static java.util.ArrayList<double[]> readRing(EWKTUtils.EWKTSource source, int dimensionSystem)
-
addRing
private static void addRing(java.util.ArrayList<double[]> ring, GeometryUtils.Target target)
-
addCoordinate
private static void addCoordinate(EWKTUtils.EWKTSource source, GeometryUtils.Target target, int dimensionSystem, int index, int total)
-
readCoordinate
private static double[] readCoordinate(EWKTUtils.EWKTSource source, int dimensionSystem)
-
getDimensionSystem
public static int getDimensionSystem(java.lang.String ewkt)
Reads the dimension system from EWKT.- Parameters:
ewkt
- EWKT source- Returns:
- the dimension system
-
-