Permalink
Browse files

initial implementation of the geospatial api.

  • Loading branch information...
1 parent bdce8f3 commit 578f2f485b86fb44aadeb9fd0ef6f4bbfd4138d4 Bill Millar committed Nov 20, 2009
@@ -1,8 +1,3 @@
-#Tue Nov 10 22:38:59 PST 2009
+#Thu Nov 19 14:28:34 PST 2009
eclipse.preferences.version=1
-encoding//src/AGRepositoryConnectionTest.java=UTF-8
-encoding//src/FooBar.java=UTF-8
-encoding//src/RepositoryConnectionTest.java=UTF-8
-encoding//src/RepositoryConnectionTestNoBNodes.java=UTF-8
-encoding//src/RepositoryConnectionTestOfficial.java=UTF-8
encoding/<project>=UTF-8
@@ -874,4 +874,167 @@ public void ping() throws RepositoryException {
}
}
+ public String[] getGeoTypes() throws RepositoryException {
+ String url = AGProtocol.getGeoTypesLocation(getSessionRoot());
+ Header[] headers = {};
+ AGResponseHandler handler = new AGResponseHandler("");
+ try {
+ getHTTPClient().get(url, headers, new NameValuePair[0], handler);
+ } catch (HttpException e) {
+ throw new RepositoryException(e);
+ } catch (IOException e) {
+ throw new RepositoryException(e);
+ } catch (AGHttpException e) {
+ throw new RepositoryException(e);
+ }
+ return handler.getString().split("\n");
+ }
+
+ public String registerCartesianType(float stripWidth, float xmin, float xmax,
+ float ymin, float ymax) throws RepositoryException {
+ String url = AGProtocol.getGeoTypesCartesianLocation(getSessionRoot());
+ Header[] headers = {};
+ NameValuePair[] params = {
+ new NameValuePair(AGProtocol.STRIP_WIDTH_PARAM_NAME, Float.toString(stripWidth)),
+ new NameValuePair(AGProtocol.XMIN_PARAM_NAME, Float.toString(xmin)),
+ new NameValuePair(AGProtocol.XMAX_PARAM_NAME, Float.toString(xmax)),
+ new NameValuePair(AGProtocol.YMIN_PARAM_NAME, Float.toString(ymin)),
+ new NameValuePair(AGProtocol.YMAX_PARAM_NAME, Float.toString(ymax))
+ };
+ AGResponseHandler handler = new AGResponseHandler("");
+ try {
+ getHTTPClient().post(url, headers, params, null, handler);
+ } catch (HttpException e) {
+ throw new RepositoryException(e);
+ } catch (RDFParseException e) {
+ throw new RepositoryException(e);
+ } catch (IOException e) {
+ throw new RepositoryException(e);
+ }
+ return handler.getString();
+ }
+
+ public String registerSphericalType(float stripWidth, String unit, float latmin, float longmin,
+ float latmax, float longmax) throws RepositoryException {
+ String url = AGProtocol.getGeoTypesSphericalLocation(getSessionRoot());
+ Header[] headers = {};
+ NameValuePair[] params = {
+ new NameValuePair(AGProtocol.STRIP_WIDTH_PARAM_NAME, Float.toString(stripWidth)),
+ new NameValuePair(AGProtocol.UNIT_PARAM_NAME, unit),
+ new NameValuePair(AGProtocol.LATMIN_PARAM_NAME, Float.toString(latmin)),
+ new NameValuePair(AGProtocol.LONGMIN_PARAM_NAME, Float.toString(longmin)),
+ new NameValuePair(AGProtocol.LATMAX_PARAM_NAME, Float.toString(latmax)),
+ new NameValuePair(AGProtocol.LONGMAX_PARAM_NAME, Float.toString(longmax))
+ };
+ AGResponseHandler handler = new AGResponseHandler("");
+ try {
+ getHTTPClient().post(url, headers, params, null, handler);
+ } catch (HttpException e) {
+ throw new RepositoryException(e);
+ } catch (RDFParseException e) {
+ throw new RepositoryException(e);
+ } catch (IOException e) {
+ throw new RepositoryException(e);
+ }
+ return handler.getString();
+ }
+
+ public void getGeoBox(String type_uri, String predicate_uri, float xmin, float xmax,
+ float ymin, float ymax, int limit, boolean infer, AGResponseHandler handler)
+ throws RepositoryException {
+ String url = AGProtocol.getGeoBoxLocation(getSessionRoot());
+ Header[] headers = { new Header(ACCEPT_PARAM_NAME,
+ getPreferredRDFFormat().getDefaultMIMEType()) };
+ List<NameValuePair> params = new ArrayList<NameValuePair>(7);
+ params.add(new NameValuePair(AGProtocol.TYPE_PARAM_NAME, type_uri));
+ params.add(new NameValuePair(AGProtocol.GEO_PREDICATE_PARAM_NAME, predicate_uri));
+ params.add(new NameValuePair(AGProtocol.XMIN_PARAM_NAME, Float.toString(xmin)));
+ params.add(new NameValuePair(AGProtocol.XMAX_PARAM_NAME, Float.toString(xmax)));
+ params.add(new NameValuePair(AGProtocol.YMIN_PARAM_NAME, Float.toString(ymin)));
+ params.add(new NameValuePair(AGProtocol.YMAX_PARAM_NAME, Float.toString(ymax)));
+ params.add(new NameValuePair(AGProtocol.INCLUDE_INFERRED_PARAM_NAME, Boolean.toString(infer)));
+ if (0!=limit) {
+ params.add(new NameValuePair(AGProtocol.LIMIT_PARAM_NAME, Integer.toString(limit)));
+ }
+ try {
+ getHTTPClient()
+ .get(
+ url,
+ headers,
+ params.toArray(new NameValuePair[params.size()]),
+ handler);
+ } catch (HttpException e) {
+ throw new RepositoryException(e);
+ } catch (AGHttpException e) {
+ throw new RepositoryException(e);
+ } catch (IOException e) {
+ throw new RepositoryException(e);
+ }
+ }
+
+ public void getGeoCircle(String type_uri, String predicate_uri, float x, float y,
+ float radius, int limit, boolean infer, AGResponseHandler handler)
+ throws RepositoryException {
+ String url = AGProtocol.getGeoCircleLocation(getSessionRoot());
+ Header[] headers = { new Header(ACCEPT_PARAM_NAME,
+ getPreferredRDFFormat().getDefaultMIMEType()) };
+ List<NameValuePair> params = new ArrayList<NameValuePair>(7);
+ params.add(new NameValuePair(AGProtocol.TYPE_PARAM_NAME, type_uri));
+ params.add(new NameValuePair(AGProtocol.GEO_PREDICATE_PARAM_NAME, predicate_uri));
+ params.add(new NameValuePair(AGProtocol.X_PARAM_NAME, Float.toString(x)));
+ params.add(new NameValuePair(AGProtocol.Y_PARAM_NAME, Float.toString(y)));
+ params.add(new NameValuePair(AGProtocol.RADIUS_PARAM_NAME, Float.toString(radius)));
+ params.add(new NameValuePair(AGProtocol.INCLUDE_INFERRED_PARAM_NAME, Boolean.toString(infer)));
+ if (0!=limit) {
+ params.add(new NameValuePair(AGProtocol.LIMIT_PARAM_NAME, Integer.toString(limit)));
+ }
+ try {
+ getHTTPClient()
+ .get(
+ url,
+ headers,
+ params.toArray(new NameValuePair[params.size()]),
+ handler);
+ } catch (HttpException e) {
+ throw new RepositoryException(e);
+ } catch (AGHttpException e) {
+ throw new RepositoryException(e);
+ } catch (IOException e) {
+ throw new RepositoryException(e);
+ }
+ }
+
+ public void getGeoHaversine(String type_uri, String predicate_uri, float lat, float lon,
+ float radius, String unit, int limit, boolean infer, AGResponseHandler handler)
+ throws RepositoryException {
+ String url = AGProtocol.getGeoHaversineLocation(getSessionRoot());
+ Header[] headers = { new Header(ACCEPT_PARAM_NAME,
+ getPreferredRDFFormat().getDefaultMIMEType()) };
+ List<NameValuePair> params = new ArrayList<NameValuePair>(7);
+ params.add(new NameValuePair(AGProtocol.TYPE_PARAM_NAME, type_uri));
+ params.add(new NameValuePair(AGProtocol.GEO_PREDICATE_PARAM_NAME, predicate_uri));
+ params.add(new NameValuePair(AGProtocol.LAT_PARAM_NAME, Float.toString(lat)));
+ params.add(new NameValuePair(AGProtocol.LON_PARAM_NAME, Float.toString(lon)));
+ params.add(new NameValuePair(AGProtocol.RADIUS_PARAM_NAME, Float.toString(radius)));
+ params.add(new NameValuePair(AGProtocol.UNIT_PARAM_NAME, unit));
+ params.add(new NameValuePair(AGProtocol.INCLUDE_INFERRED_PARAM_NAME, Boolean.toString(infer)));
+ if (0!=limit) {
+ params.add(new NameValuePair(AGProtocol.LIMIT_PARAM_NAME, Integer.toString(limit)));
+ }
+ try {
+ getHTTPClient()
+ .get(
+ url,
+ headers,
+ params.toArray(new NameValuePair[params.size()]),
+ handler);
+ } catch (HttpException e) {
+ throw new RepositoryException(e);
+ } catch (AGHttpException e) {
+ throw new RepositoryException(e);
+ } catch (IOException e) {
+ throw new RepositoryException(e);
+ }
+ }
+
}
@@ -126,7 +126,7 @@
public static final String FTI_PREDICATES = "predicates";
/**
- * Parameter name for the 'on' parameter of autoCommit.
+ * Parameter name for the 'predicate' parameter for freetext.
*/
public static final String FTI_PREDICATE_PARAM_NAME = "predicate";
@@ -174,7 +174,146 @@
* Parameter name for the 'planner' to use during a query
*/
public static final String PLANNER_PARAM_NAME = "planner";
+
+ /**
+ * Relative location of the Geo service.
+ */
+ public static final String GEO = "geo";
+ /**
+ * Relative location of the Geo Types service.
+ */
+ public static final String TYPES = "types";
+
+ /**
+ * Relative location of the Geo Types Cartesian service.
+ */
+ public static final String CARTESIAN = "cartesian";
+
+ /**
+ * Relative location of the Geo Types Spherical service.
+ */
+ public static final String SPHERICAL = "spherical";
+
+ /**
+ * Parameter name for the 'stripWidth' of a Geo type
+ */
+ public static final String STRIP_WIDTH_PARAM_NAME = "stripWidth";
+
+ /**
+ * Parameter name for the 'xmin' of a Geo type
+ */
+ public static final String XMIN_PARAM_NAME = "xmin";
+
+ /**
+ * Parameter name for the 'xmax' of a Geo type
+ */
+ public static final String XMAX_PARAM_NAME = "xmax";
+
+ /**
+ * Parameter name for the 'ymin' of a Geo type
+ */
+ public static final String YMIN_PARAM_NAME = "ymin";
+
+ /**
+ * Parameter name for the 'ymax' of a Geo type
+ */
+ public static final String YMAX_PARAM_NAME = "ymax";
+
+ /**
+ * Parameter name for the 'latmin' of a Geo type
+ */
+ public static final String LATMIN_PARAM_NAME = "latmin";
+
+ /**
+ * Parameter name for the 'longmin' of a Geo type
+ */
+ public static final String LONGMIN_PARAM_NAME = "longmin";
+
+ /**
+ * Parameter name for the 'latmax' of a Geo type
+ */
+ public static final String LATMAX_PARAM_NAME = "latmax";
+
+ /**
+ * Parameter name for the 'longmax' of a Geo type
+ */
+ public static final String LONGMAX_PARAM_NAME = "longmax";
+
+ /**
+ * Parameter name for the 'unit' of a Geo type
+ */
+ public static final String UNIT_PARAM_NAME = "unit";
+
+ /**
+ * Parameter value 'degree' for the 'unit' of a Geo type
+ */
+ public static final String DEGREE_PARAM_VALUE = "degree";
+
+ /**
+ * Parameter value 'radian' for the 'unit' of a Geo type
+ */
+ public static final String RADIAN_PARAM_VALUE = "radian";
+
+ /**
+ * Parameter value 'km' for the 'unit' of a Geo type
+ */
+ public static final String KM_PARAM_VALUE = "km";
+
+ /**
+ * Parameter value 'mile' for the 'unit' of a Geo type
+ */
+ public static final String MILE_PARAM_VALUE = "mile";
+
+ /**
+ * Parameter name for the 'limit' on results returned.
+ */
+ public static final String LIMIT_PARAM_NAME = "limit";
+
+ /**
+ * Relative location of the Geo Box service.
+ */
+ public static final String BOX = "box";
+
+ /**
+ * Parameter name for the 'predicate' to search for in geo searches.
+ */
+ public static final String GEO_PREDICATE_PARAM_NAME = "predicate";
+
+ /**
+ * Relative location of the Geo Circle service.
+ */
+ public static final String CIRCLE = "circle";
+
+ /**
+ * Parameter name for the 'x' ordinate of a circle
+ */
+ public static final String X_PARAM_NAME = "x";
+
+ /**
+ * Parameter name for the 'y' ordinate of a circle
+ */
+ public static final String Y_PARAM_NAME = "y";
+
+ /**
+ * Parameter name for the 'radius' of a circle
+ */
+ public static final String RADIUS_PARAM_NAME = "radius";
+
+ /**
+ * Relative location of the Geo Haversine service.
+ */
+ public static final String HAVERSINE = "haversine";
+
+ /**
+ * Parameter name for the 'lat' ordinate of a haversine
+ */
+ public static final String LAT_PARAM_NAME = "lat";
+
+ /**
+ * Parameter name for the 'lon' ordinate of a haversine
+ */
+ public static final String LON_PARAM_NAME = "lon";
/**
* Location of the root catalog service
@@ -278,5 +417,33 @@ public static String getFederatedRepositoriesLocation(String catalogURL) {
public static String getEvalLocation(String sessionRoot) {
return sessionRoot + "/" + EVAL;
}
+
+ public static String getGeoLocation(String sessionRoot) {
+ return sessionRoot + "/" + GEO;
+ }
+
+ public static String getGeoTypesLocation(String sessionRoot) {
+ return getGeoLocation(sessionRoot) + "/" + TYPES;
+ }
+
+ public static String getGeoTypesCartesianLocation(String sessionRoot) {
+ return getGeoTypesLocation(sessionRoot) + "/" + CARTESIAN;
+ }
+
+ public static String getGeoTypesSphericalLocation(String sessionRoot) {
+ return getGeoTypesLocation(sessionRoot) + "/" + SPHERICAL;
+ }
+
+ public static String getGeoBoxLocation(String sessionRoot) {
+ return getGeoLocation(sessionRoot) + "/" + BOX;
+ }
+
+ public static String getGeoCircleLocation(String sessionRoot) {
+ return getGeoLocation(sessionRoot) + "/" + CIRCLE;
+ }
+
+ public static String getGeoHaversineLocation(String sessionRoot) {
+ return getGeoLocation(sessionRoot) + "/" + HAVERSINE;
+ }
}
Oops, something went wrong.

0 comments on commit 578f2f4

Please sign in to comment.