public class Assistant
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
private static Configuration |
currentConfig |
private java.text.DecimalFormat |
decDateFormatter |
private static com.vividsolutions.jts.geom.Geometry |
extent |
private java.text.SimpleDateFormat |
gmtDateFormat |
private static java.util.Set<java.lang.String> |
ISO_LANGUAGES |
private com.ibm.icu.text.Transliterator |
latinTransliterator |
private static Expr |
logicalFilter |
private static com.vividsolutions.jts.geom.Envelope |
mbr |
private java.util.concurrent.atomic.AtomicLong |
numberGenerator |
PGDBDecoder |
pgdbDecoder |
private java.text.SimpleDateFormat |
standardDateFormat |
com.vividsolutions.jts.io.WKTReader |
wktReader |
Constructor and Description |
---|
Assistant()
Constructor of the class without explicit declaration of configuration settings.
|
Assistant(Configuration config)
Constructor of the class with explicit declaration of configuration settings.
|
Modifier and Type | Method and Description |
---|---|
void |
addLineString(com.vividsolutions.jts.geom.LineString lineString,
com.vividsolutions.jts.operation.polygonize.Polygonizer polygonizer)
Add the linestring given to the polygonizer
|
void |
addPolygon(com.vividsolutions.jts.geom.Polygon polygon,
com.vividsolutions.jts.operation.polygonize.Polygonizer polygonizer)
Add all line strings from the polygon given to the polygonizer
|
java.lang.Object |
applyRuntimeMethod(java.lang.String methodName,
java.lang.Object[] args)
Applies a function at runtime, based on user-defined YML specifications regarding an attribute.
|
java.lang.String |
blob2WKT(java.sql.Blob blob,
org.opengis.referencing.operation.MathTransform transform)
Transforms a BLOB representation of a geometry contained in an ESRI personal geodatabase (.mdb) into WKT.
|
boolean |
check_ShapefileFolder(java.lang.String inputFolder)
Checks if the the input is correct.
|
private boolean |
check_ShapeFiles(java.lang.String inputFolder)
Checks if folder contains the necessary files of Shapefile.
|
void |
cleanupFilesInDir(java.lang.String path)
Removes all files from a given directory.
|
java.lang.String |
concatenate(java.lang.String[] values)
Built-in function that concatenates an array of multiple string values into a unified one.
|
java.lang.String |
concatenate(java.lang.String val1,
java.lang.String val2)
Built-in function that concatenates a pair of string values into a new one.
|
java.lang.String |
convertInputStreamToString(java.io.InputStream is)
Returns a String with the content of the InputStream
|
java.io.InputStream |
convertStringToInputStream(java.lang.String string)
Returns an InputStream with the content of the given string.
|
java.lang.String |
createDirectory(java.lang.String path)
Creates a temporary directory under the specified path.
|
java.lang.String |
encodeUTF(java.lang.String s,
java.lang.String encoding)
Provides a UTF-8 encoding of the given string originally represented in the given encoding
|
boolean |
filterContains(java.lang.String wkt)
Specify a topological filter (CONTAINS) against input geometries in order to exclude transformation of those outside a user-specified spatial extent.
|
boolean |
filterThematic(java.util.Map<java.lang.String,java.lang.String> record)
Evaluates a thematic filter (logical expression) over an input data record.
|
java.lang.String |
geometry2WKT(com.vividsolutions.jts.geom.Geometry g,
java.lang.String geomOntology)
Provides the Well-Known Text representation of a geometry for its inclusion as literal in RDF triples.
|
com.vividsolutions.jts.geom.Geometry |
geomFlatTransform(com.vividsolutions.jts.geom.Geometry g,
int srid)
Projects the given geometry to a flat Cartesian plane
|
com.vividsolutions.jts.geom.Geometry |
geomTransform(com.vividsolutions.jts.geom.Geometry g,
org.opengis.referencing.operation.MathTransform transform)
Transforms an original geometry into another CRS (reprojection).
|
com.vividsolutions.jts.geom.Geometry |
geomTransformWGS84(java.lang.String wkt,
int srid)
Reprojects a given geometry into the WGS84 (lon/lat) coordinate reference system
|
com.vividsolutions.jts.geom.Geometry |
geomValidate(com.vividsolutions.jts.geom.Geometry geom)
Get / create a valid version of the geometry given.
|
double |
getArea(java.lang.String polygonWKT)
Returns the area of a polygon geometry from its the Well-Known Text representation.
|
double |
getArea(java.lang.String polygonWKT,
int srid)
Built-in function that returns the area of a polygon geometry from its the Well-Known Text representation.
|
java.lang.String |
getDataSource()
Built-in function that identifies the provider of the dataset as specified in the configuration settings.
|
java.lang.String |
getFileFromShapefile(java.lang.String extension,
java.lang.String inputFolder)
Returns the absolute path of the requested file from the shapefile collection.
|
com.vividsolutions.jts.geom.Geometry |
getFilterExtent()
Returns the geometry that represents the spatial filter that is being applied to select features from the input dataset.
|
java.lang.String |
getGeoHash(double lon,
double lat,
int precision)
Encode a geographic location into a short string of letters and digits, according to http://geohash.org/
|
java.lang.String |
getGMTime()
Get the current time (in the GMT time zone) to be used in user notifications.
|
java.lang.String |
getLanguage(java.lang.String attr,
int i)
Built-in function that extracts the language tag from an attribute name.
|
double |
getLatitude(com.vividsolutions.jts.geom.Geometry g)
Calculate the latitude at the centroid of the geometry
|
double |
getLength(java.lang.String wkt)
Returns the length of a linestring or the perimeter of a polygon geometry from its the Well-Known Text representation.
|
double |
getLength(java.lang.String wkt,
int srid)
Built-in function that returns the length of a linestring or the perimeter of a polygon geometry from its the Well-Known Text representation.
|
Expr |
getLogicalExpression(java.lang.String condition)
Returns a logical expression to be evaluated against a record (represented as a Map with key-value pairs); evaluation returns a boolean value.
|
double |
getLongitude(com.vividsolutions.jts.geom.Geometry g)
Calculate the longitude at the centroid of the geometry
|
double[] |
getLonLatCoords(java.lang.String wkt,
int srid)
Built-in function that returns a pair of lon/lat coordinates (in WGS84) of a geometry as calculated from its the Well-Known Text representation.
|
com.vividsolutions.jts.geom.Envelope |
getMBR()
Provides the MBR of the geographic dataset that has been transformed.
|
long |
getNextSerial()
Provides the next serial number (long) to be used as an intermediate identifier
|
java.lang.String |
getOutputExtension(java.lang.String serialization)
Determines the file extension of the output file(s), depending on the RDF serialization.
|
java.lang.String |
getRandomUUID()
Built-in function that provides a UUID (Universally Unique Identifier) that represents a 128-bit long value to be used in the URI of a transformed feature.
|
org.apache.jena.riot.Lang |
getRDFLang(java.lang.String serialization)
Determines the serialization mode in the output RDF triples.
|
org.openrdf.rio.RDFFormat |
getRDFSerialization(java.lang.String serialization)
Determines the serialization mode in the output RDF triples.
|
java.lang.String |
getResourceType(java.lang.String val)
Built-in function that assigns a value as the type of a resource.
|
java.lang.String |
getTransliteration(java.lang.String val)
Built-in function that provides a transliteration into phonetically equivalent Latin characters of a string literal written in a non-Latin alphabet.
|
java.lang.String |
getUUID(java.lang.String id)
Built-in function that provides a UUID (Universally Unique Identifier) that represents a 128-bit long value to be used in the URI of a transformed feature.
|
java.lang.String |
getUUID(java.lang.String featureSource,
java.lang.String id)
Built-in function that provides a UUID (Universally Unique Identifier) that represents a 128-bit long value to be used in the URI of a transformed feature.
|
boolean |
hasSpatialExtent()
Check whether there is a user-specified spatial filter (CONTAINS) against input data.
|
boolean |
hasSQLFilter()
Check whether there is a user-specified SQL filter against input data.
|
boolean |
initPGDBDecoder()
Instantiates a new PGDBDecoder for geometries from a Personal ESRI geodatabase (MS Access format).
|
boolean |
isNullOrEmpty(java.lang.String text)
Examines whether a given string is null or empty (blank).
|
boolean |
isValidISOLanguage(java.lang.String s)
Checks if the given string represents a valid ISO 639-1 language code (2 digits)
|
java.lang.String |
keepOriginalID(java.lang.String id)
Build-in function that retains the original identifier of a feature in the resulting URI or the transformed resource.
|
void |
mergeFiles(java.util.List<java.lang.String> inputFiles,
java.lang.String outputFile)
Merges several input files into a single output file.
|
void |
notifyProgress(int numRec)
Notifies the user about progress in parsing input records.
|
void |
notifyProgress(int numRec,
int partition_index)
Notifies the user about progress in parsing input records.
|
private java.lang.String |
printMBR(com.vividsolutions.jts.geom.Envelope mbr)
Prints the MBR of the transformed geometries.
|
java.lang.String |
removeDirectory(java.lang.String path)
Removes a given directory and all its contents.
|
void |
reportStatistics(long dt,
int numRec,
int rejectedRec,
int numTriples,
java.lang.String serialization,
java.util.Map<java.lang.String,java.lang.Integer> attrStatistics,
com.vividsolutions.jts.geom.Envelope mbr,
java.lang.String mode,
java.lang.String targetSRID,
java.lang.String outputFile)
Report statistics upon termination of the reverse transformation process.
|
void |
reportStatistics(long dt,
int numRec,
int rejectedRec,
int numTriples,
java.lang.String serialization,
java.util.Map<java.lang.String,java.lang.Integer> attrStatistics,
com.vividsolutions.jts.geom.Envelope mbr,
java.lang.String mode,
java.lang.String targetSRID,
java.lang.String outputFile,
int partition_index)
Report statistics upon termination of the transformation process.
|
void |
saxonTransform(java.lang.String sourcePath,
java.lang.String xsltPath,
java.lang.String resultPath)
Simple transformation method using Saxon XSLT 2.0 processor.
|
java.lang.String |
standardizeDate(java.lang.String val,
java.lang.String format)
Convert a date value from its original format into a standard timestamp value.
|
java.lang.String |
standardizePhoneNumber(java.lang.String phone,
java.lang.String country_code)
Built-in function that brings phone numbers into a consistent format.
|
com.vividsolutions.jts.geom.Geometry |
toPolygonGeometry(java.util.Collection<com.vividsolutions.jts.geom.Polygon> polygons,
com.vividsolutions.jts.geom.GeometryFactory factory)
Get a geometry from a collection of polygons.
|
void |
updateMBR(com.vividsolutions.jts.geom.Geometry g)
Updates the MBR of the geographic dataset as this is being transformed.
|
com.vividsolutions.jts.geom.Geometry |
WKT2Geometry(java.lang.String wkt)
Returns the internal geometry representation according to its Well-Known Text serialization.
|
com.vividsolutions.jts.geom.Geometry |
WKT2GeometryTransform(java.lang.String wkt,
org.opengis.referencing.operation.MathTransform transform,
com.vividsolutions.jts.io.WKTReader wktReader)
Provides the internal geometry representation based on its the Well-Known Text, also applying transformation into another CRS (if required).
|
java.lang.String |
wktTransform(java.lang.String wkt,
org.opengis.referencing.operation.MathTransform transform)
Transforms a WKT representation of a geometry into another CRS (reprojection).
|
public PGDBDecoder pgdbDecoder
public com.vividsolutions.jts.io.WKTReader wktReader
private static com.vividsolutions.jts.geom.Envelope mbr
private static com.vividsolutions.jts.geom.Geometry extent
private static Expr logicalFilter
private static Configuration currentConfig
private static java.util.Set<java.lang.String> ISO_LANGUAGES
private java.util.concurrent.atomic.AtomicLong numberGenerator
private java.text.SimpleDateFormat standardDateFormat
private java.text.SimpleDateFormat gmtDateFormat
private java.text.DecimalFormat decDateFormatter
private com.ibm.icu.text.Transliterator latinTransliterator
public Assistant()
public Assistant(Configuration config)
public org.openrdf.rio.RDFFormat getRDFSerialization(java.lang.String serialization)
serialization
- A string with the user-specified serialization.public org.apache.jena.riot.Lang getRDFLang(java.lang.String serialization)
serialization
- A string with the user-specified serialization.public java.lang.String getOutputExtension(java.lang.String serialization)
serialization
- A string with the user-specified serialization.public boolean isNullOrEmpty(java.lang.String text)
text
- The input stringpublic boolean hasSpatialExtent()
public boolean hasSQLFilter()
public java.lang.String convertInputStreamToString(java.io.InputStream is) throws java.io.IOException
is
- the InputStream.java.io.IOException
public java.io.InputStream convertStringToInputStream(java.lang.String string)
string
- A string to be converted.public java.lang.String getGMTime()
public void notifyProgress(int numRec)
numRec
- The number of records processed so far.public void notifyProgress(int numRec, int partition_index)
numRec
- The number of records processed so far.partition_index
- The index of the partition.public void reportStatistics(long dt, int numRec, int rejectedRec, int numTriples, java.lang.String serialization, java.util.Map<java.lang.String,java.lang.Integer> attrStatistics, com.vividsolutions.jts.geom.Envelope mbr, java.lang.String mode, java.lang.String targetSRID, java.lang.String outputFile, int partition_index)
dt
- The clock time (in milliseconds) elapsed since the start of transformation process.numRec
- The total number of input records that have been processed.rejectedRec
- The total number of input records that were rejected during processing.numTriples
- The number of RDF triples resulted from transformation.serialization
- A string with the user-specified serialization of output triples.attrStatistics
- Statistics collected per attribute during transformation.mbr
- The MBR of transformed geometries (in WGS1984 georeference).mode
- Transformation mode, as specified in the configuration.targetSRID
- Output spatial reference system (CRS).outputFile
- Path to the output file containing the RDF triples.partition_index
- The identifier (index) of the partition in case of Spark execution.public void reportStatistics(long dt, int numRec, int rejectedRec, int numTriples, java.lang.String serialization, java.util.Map<java.lang.String,java.lang.Integer> attrStatistics, com.vividsolutions.jts.geom.Envelope mbr, java.lang.String mode, java.lang.String targetSRID, java.lang.String outputFile)
dt
- The clock time (in milliseconds) elapsed since the start of transformation process.numRec
- The total number of input records that have been processed.rejectedRec
- The total number of input records that were rejected during processing.numTriples
- The number of RDF triples resulted from transformation.serialization
- A string with the user-specified serialization of output triples.attrStatistics
- Statistics collected per attribute during transformation.mbr
- The MBR of transformed geometries (in WGS1984 georeference).mode
- Transformation mode, as specified in the configuration.targetSRID
- Output spatial reference system (CRS).outputFile
- Path to the output file containing the RDF triples.public java.lang.String removeDirectory(java.lang.String path)
path
- The path to the directory.public void cleanupFilesInDir(java.lang.String path)
path
- The path to the directory.public java.lang.String createDirectory(java.lang.String path)
path
- The path to the directory.public void saxonTransform(java.lang.String sourcePath, java.lang.String xsltPath, java.lang.String resultPath)
sourcePath
- Absolute path to source GML file.xsltPath
- Absolute path to XSLT file.resultPath
- Absolute path to the resulting RDF file.public void updateMBR(com.vividsolutions.jts.geom.Geometry g)
g
- Geometry that will be checked for possible expansion of the MBR of all features processed thus farpublic com.vividsolutions.jts.geom.Envelope getMBR()
private java.lang.String printMBR(com.vividsolutions.jts.geom.Envelope mbr)
public java.lang.String wktTransform(java.lang.String wkt, org.opengis.referencing.operation.MathTransform transform)
wkt
- Input geometry in Well-Known Text.transform
- Parameters for the transformation, including source and target CRS.public com.vividsolutions.jts.geom.Geometry geomTransform(com.vividsolutions.jts.geom.Geometry g, org.opengis.referencing.operation.MathTransform transform)
g
- Input geometrytransform
- Parameters for the transformation, including source and target CRSpublic com.vividsolutions.jts.geom.Geometry geomTransformWGS84(java.lang.String wkt, int srid)
wkt
- Well-Known Text of the input geometrysrid
- EPSG code of the coordinate reference system (CRS) of the geometrypublic com.vividsolutions.jts.geom.Geometry geomFlatTransform(com.vividsolutions.jts.geom.Geometry g, int srid)
g
- Input geometrysrid
- EPSG code of the coordinate reference system (CRS) of the geometrypublic boolean initPGDBDecoder()
public java.lang.String blob2WKT(java.sql.Blob blob, org.opengis.referencing.operation.MathTransform transform)
blob
- Input geometry BLOBtransform
- Parameters for the (optional) transformation, including source and target CRSpublic com.vividsolutions.jts.geom.Geometry geomValidate(com.vividsolutions.jts.geom.Geometry geom)
geom
- Input geometrypublic void addPolygon(com.vividsolutions.jts.geom.Polygon polygon, com.vividsolutions.jts.operation.polygonize.Polygonizer polygonizer)
polygon
- Polygon from which to extract line stringspolygonizer
- Polygonizer objectpublic void addLineString(com.vividsolutions.jts.geom.LineString lineString, com.vividsolutions.jts.operation.polygonize.Polygonizer polygonizer)
lineString
- Line stringpolygonizer
- Polygonizer objectpublic com.vividsolutions.jts.geom.Geometry toPolygonGeometry(java.util.Collection<com.vividsolutions.jts.geom.Polygon> polygons, com.vividsolutions.jts.geom.GeometryFactory factory)
polygons
- Collection of polygonsfactory
- Factory to generate MultiPolygon if requiredpublic java.lang.String geometry2WKT(com.vividsolutions.jts.geom.Geometry g, java.lang.String geomOntology)
g
- Input geometry
$param geomOntology RDF ontology used in geometry representations (GeoSPARQL, Virtuoso geometry RDF, or WGS84 Geoposition RDF vocabulary)public com.vividsolutions.jts.geom.Geometry WKT2Geometry(java.lang.String wkt)
wkt
- WKT of the geometrypublic double getArea(java.lang.String polygonWKT)
polygonWKT
- WKT of the polygonpublic double getArea(java.lang.String polygonWKT, int srid)
polygonWKT
- WKT of the polygonsrid
- EPSG code of the coordinate reference system (CRS) of the geometrypublic double getLength(java.lang.String wkt)
wkt
- WKT of the linestring or polygonpublic double getLength(java.lang.String wkt, int srid)
wkt
- WKT of the linestring or polygonsrid
- EPSG code of the coordinate reference system (CRS) of the geometrypublic double[] getLonLatCoords(java.lang.String wkt, int srid)
wkt
- WKT of the geometrysrid
- the EPSG code of the CRS of this geometrypublic double getLongitude(com.vividsolutions.jts.geom.Geometry g)
g
- Input geometrypublic double getLatitude(com.vividsolutions.jts.geom.Geometry g)
g
- Input geometrypublic com.vividsolutions.jts.geom.Geometry WKT2GeometryTransform(java.lang.String wkt, org.opengis.referencing.operation.MathTransform transform, com.vividsolutions.jts.io.WKTReader wktReader)
wkt
- WKT of the geometrytransform
- Parameters for the transformation, including source and target CRSwktReader
- Parser of WKT geometry representationspublic java.lang.String getGeoHash(double lon, double lat, int precision)
lon
- Longitude of the locationlat
- Latitude of the locationprecision
- The length of the geohash stringpublic boolean filterContains(java.lang.String wkt)
wkt
- Input geometry as WKTpublic com.vividsolutions.jts.geom.Geometry getFilterExtent()
public boolean filterThematic(java.util.Map<java.lang.String,java.lang.String> record)
record
- Input data record (including all thematic attributes available in the original feature)public void mergeFiles(java.util.List<java.lang.String> inputFiles, java.lang.String outputFile)
inputFiles
- List of the paths to the input files
$param outputFile Path to merged output filepublic java.lang.String getTransliteration(java.lang.String val)
val
- The original string literal (may contain Latin characters).public java.lang.String standardizeDate(java.lang.String val, java.lang.String format)
val
- Input date value (given as a string)format
- Original format of date values as specified in the mappings.public java.lang.String standardizePhoneNumber(java.lang.String phone, java.lang.String country_code)
phone
- The original string literal representing a phone numbercountry_code
- The international country code of this phone number (e.g., 49 for Germany, 30 for Greece, etc.)public long getNextSerial()
public java.lang.String getUUID(java.lang.String featureSource, java.lang.String id)
featureSource
- The name of the feature source, to be used as suffix of the identifier.id
- A unique identifier of the feature.public java.lang.String getUUID(java.lang.String id)
id
- A unique identifier of the feature.public java.lang.String getRandomUUID()
public java.lang.String keepOriginalID(java.lang.String id)
id
- A unique identifier of the feature.public java.lang.String encodeUTF(java.lang.String s, java.lang.String encoding)
s
- input string valueencoding
- name of the character encodingpublic boolean isValidISOLanguage(java.lang.String s)
s
- An input string valuepublic java.lang.String getLanguage(java.lang.String attr, int i)
attr
- The attribute name.i
- Index of the i-th character in the attribute name.public java.lang.String getResourceType(java.lang.String val)
val
- The value to be assigned as the type of the resource.public java.lang.String getDataSource()
public java.lang.String concatenate(java.lang.String val1, java.lang.String val2)
val1
- The first value.val2
- The second value.public java.lang.String concatenate(java.lang.String[] values)
values
- The array of string values.public Expr getLogicalExpression(java.lang.String condition)
condition
- An SQL condition involving equality, possibly combining several subexpressions with AND, ORpublic java.lang.Object applyRuntimeMethod(java.lang.String methodName, java.lang.Object[] args)
methodName
- The name of the method to invoke (e.g., getLanguage).args
- The necessary arguments for the method to run (may be multiple).public boolean check_ShapefileFolder(java.lang.String inputFolder)
inputFolder
- the path to the input folder.private boolean check_ShapeFiles(java.lang.String inputFolder)
inputFolder
- the path to the input folder.public java.lang.String getFileFromShapefile(java.lang.String extension, java.lang.String inputFolder)
extension:
- the extension of the file that will search for in the collection.inputFolder
- the path to the input folder.