AGGeospatialBoundingBoxSpherical.java
package com.franz.ag.examples;
import com.franz.ag.*;
public class AGGeospatialBoundingBoxSpherical {
@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("geospatialboundingbox", AGPaths.TRIPLE_STORES);
ts.registerNamespace("ex","http://example.org/");
GeoExtension geo = ts.getGeoExtension();
GeospatialSubtype subtype = geo.registerLatitudeStripingInMiles(50.0);
geo.addSubtype(subtype);
UPI upiA = geo.encodeUPI(subtype, -122, 37);
UPI upiB = geo.encodeUPI(subtype, -121, 37);
UPI upiC = geo.encodeUPI(subtype, -120, 37);
UPI upiD = geo.encodeUPI(subtype, -121, 36);
UPI upiE = geo.encodeUPI(subtype, -121, 38);
ts.addStatement("!ex:pointA", "!ex:location", upiA);
ts.addStatement("!ex:pointB", "!ex:location", upiB);
ts.addStatement("!ex:pointC", "!ex:location", upiC);
ts.addStatement("!ex:pointD", "!ex:location", upiD);
ts.addStatement("!ex:pointE", "!ex:location", upiE);
AGUtils.indexAllTriplesWithTiming(ts);
Cursor cc = ts.getStatements(null,null,null);
AGUtils.showTriples("All triples:",cc);
cc = geo.getStatementsInBoundingBox(subtype, "!ex:location", -122, -120, 36, 38, false, false);
AGUtils.showTriples("Triples in bounding box:",cc);
ts.closeTripleStore();
ags.disable();
}
}
Up |
Next