public class JsonToRdf
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
private Classification |
classification |
private static org.opengis.referencing.crs.CRSAuthorityFactory |
crsFactory |
private Configuration |
currentConfig |
private java.lang.String |
inputFile |
(package private) Assistant |
myAssistant |
(package private) Converter |
myConverter |
private java.lang.String |
outputFile |
private org.opengis.referencing.operation.MathTransform |
reproject |
(package private) int |
sourceSRID |
(package private) int |
targetSRID |
Constructor and Description |
---|
JsonToRdf(Configuration config,
Classification classific,
java.lang.String inFile,
java.lang.String outFile,
int sourceSRID,
int targetSRID)
Constructor for the transformation process from JSON document to RDF.
|
Modifier and Type | Method and Description |
---|---|
void |
apply()
Applies transformation according to the configuration settings.
|
private void |
flattener(java.util.Map<java.lang.String,java.lang.String> record,
java.util.Map.Entry<java.lang.String,com.fasterxml.jackson.databind.JsonNode> node,
java.util.List<java.lang.String> names)
Flattens any nested properties in the given JSON node.
|
private void |
parseArrayNode(com.fasterxml.jackson.databind.node.ArrayNode arrayNode)
Parses an array of object nodes, by invoking processing for each of them.
|
private void |
parseDocument(byte[] json)
Parse each item in the input JSON document in order to create the necessary triples (including geometric and non-spatial attributes).
|
private void |
parseNestedArray(java.util.Map<java.lang.String,java.lang.String> record,
java.lang.String key,
com.fasterxml.jackson.databind.node.ArrayNode arrayNode)
Handles a nested array of properties under an identified object (feature), by essentially parsing each of them.
|
private void |
parseNestedArrayNode(java.util.Map<java.lang.String,java.lang.String> record,
java.lang.String key,
int k,
com.fasterxml.jackson.databind.JsonNode jsonNode)
Parses and possibly flattens a JSON properties node (i.e., properties listed as distinct items in an array).
|
private java.util.Map<java.lang.String,java.lang.String> |
parseObjectNode(com.fasterxml.jackson.databind.JsonNode jsonNode)
Parses and possibly flattens a JSON object node.
|
private void |
processRecord(java.util.Map<java.lang.String,java.lang.String> record)
Submit a single feature (with a geometry and all its non-spatial properties) for transformation.
|
Converter myConverter
Assistant myAssistant
private org.opengis.referencing.operation.MathTransform reproject
int sourceSRID
int targetSRID
private Configuration currentConfig
private Classification classification
private java.lang.String inputFile
private java.lang.String outputFile
private static final org.opengis.referencing.crs.CRSAuthorityFactory crsFactory
public JsonToRdf(Configuration config, Classification classific, java.lang.String inFile, java.lang.String outFile, int sourceSRID, int targetSRID) throws java.lang.ClassNotFoundException
config
- Parameters to configure the transformation.classific
- Instantiation of the classification scheme that assigns categories to input features.inFile
- Path to input JSON file.outFile
- Path to the output file that collects RDF triples.sourceSRID
- Spatial reference system (EPSG code) of the input JSON file.targetSRID
- Spatial reference system (EPSG code) of geometries in the output RDF triples.java.lang.ClassNotFoundException
public void apply()
private java.util.Map<java.lang.String,java.lang.String> parseObjectNode(com.fasterxml.jackson.databind.JsonNode jsonNode)
jsonNode
- The JSON node to be parsed.private void parseNestedArrayNode(java.util.Map<java.lang.String,java.lang.String> record, java.lang.String key, int k, com.fasterxml.jackson.databind.JsonNode jsonNode)
record
- A map updated with (flattened) properties as keys and their respective values as identified in the given JSON node.key
- The name of the parent property.k
- The serial number of the item in the underlying array.jsonNode
- The JSON node to be parsed.private void parseNestedArray(java.util.Map<java.lang.String,java.lang.String> record, java.lang.String key, com.fasterxml.jackson.databind.node.ArrayNode arrayNode)
key
- The name of the parent property.arrayNode
- A JSON node representing an array of children nodes.private void parseArrayNode(com.fasterxml.jackson.databind.node.ArrayNode arrayNode)
arrayNode
- The parent node representing an array of object nodes.private void flattener(java.util.Map<java.lang.String,java.lang.String> record, java.util.Map.Entry<java.lang.String,com.fasterxml.jackson.databind.JsonNode> node, java.util.List<java.lang.String> names)
record
- Map structure to collect the flattened properties (keys) and their values.node
- JSON node to be flattened.names
- Prefix names for the keys to be generated.private void processRecord(java.util.Map<java.lang.String,java.lang.String> record)
record
- Map structure that has collected all flattened properties (as keys) and their respective values.private void parseDocument(byte[] json)
json
- The JSON document having (maybe nested) properties per item.