AGGeospatialLoaderSerializer.java
package com.franz.ag.examples;
import com.franz.ag.*;
public class AGGeospatialLoaderSerializer {
@param
@throws
public static void main(String[] args) throws AllegroGraphException {
AllegroGraphConnection ags = new AllegroGraphConnection();
try {
ags.enable();
} catch (Exception e) {
throw new AllegroGraphException("Server connection problem", e);
}
AllegroGraph ts = ags.renew("geospatialloadserialize", AGPaths.TRIPLE_STORES);
ts.registerNamespace("ex","http://example.org/places/");
ts.registerNamespace("geo","http://franz.com/ns/allegrograph/3.0/geospatial/");
GeoExtension geo = ts.getGeoExtension();
GeospatialSubtype subtype50 = geo.registerLatitudeStripingInMiles(50.0);
geo.addSubtype(subtype50);
UPI upi = geo.encodeUPI(subtype50, -122.31307, 37.86385);
Object[] location = geo.decodeUPI(upi);
AGUtils.printObjectArray("Location:", location);
ts.addStatement("!ex:Berkeley", "!ex:location", upi);
Cursor cc = ts.getStatements(null,null,null);
AGUtils.showTriples(cc);
NTriplesSerializer ntser = new NTriplesSerializer();
ntser.setDestination(AGPaths.dataSources("geospatial-serialized.nt"));
ntser.setIfExists("supersede");
ntser.run(ts);
ts.closeTripleStore();
ags.disable();
}
}
Up |
Next