AGGeospatialBoundingBox.java
package com.franz.ag.examples;
import com.franz.ag.*;
public class AGGeospatialBoundingBox {
@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.registerCartesianStriping(0,1,0,1,.01);
geo.addSubtype(subtype);
UPI upiA = geo.encodeUPI(subtype, 0, 0);
UPI upiB = geo.encodeUPI(subtype, .25, .75);
UPI upiC = geo.encodeUPI(subtype, .5, .5);
UPI upiD = geo.encodeUPI(subtype, .75, .25);
UPI upiE = geo.encodeUPI(subtype, 1, 1);
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", 0, .9, 0, .9, false, false);
AGUtils.showTriples("Triples in bounding box:",cc);
ts.closeTripleStore();
ags.disable();
}
}
Up |
Next