Geomark Web Service Client API

Geomark Java Client API allows client applications to use the Geomark REST Web Service API to Construct a newnd access Geomarks on behalf of their users.

The client can be used from Maven applications using the following Maven settings

package ca.bc.gov.geomark.client.api

The Geomark Java Client API classes.

class GeomarkClient

The Geomark Java (11+) client allows applications to use the Geomark Web Service REST API to create geomarks, get geomark info, download geomarks and manage geomark groups.

Construct a new Geomark client that is not connected to a specific Geomark server. This client can only be used to get the geomark info, or geometry using full geomark URL's. It cannot be used to add geomarks or manage groups.

Construct a new Geomark client that is connected to a specific Geomark web service (e.g. https://apps.gov.bc.ca/pub/geomark). This client can also get the geomark info, or download geomark geometry using full geomark URL's from other servers.

ParameterTypeDescription
serverUrl String The base URL to the geomark server.

Construct a new new geomark from an InputStream containing the geometry using the Create Geomark REST API.

The extended parameters to the method are passed in using a Java (map). See the Create Geomark Copy REST API for the list of supported parameters.

The following code fragment shows an example of using the API.


 String baseUrl = "https://apps.gov.bc.ca/pub/geomark";
 GeomarkClient client = new GeomarkClient(baseUrl);

 InputStream geometry = new FileInputStream("...");

 Map<String, Object> parameters = new HashMap<String, Object>();
 parameters.put(GeomarkClient.SRID, 4326);
 parameters.put(GeomarkClient.FORMAT, "wkt");

 String geomarkUrl = client.addGeomark(geometry, parameters);
 System.out.println(geomarkUrl);
 
ParameterTypeDescription
geometry InputStream The text of geometry to create the geomark for.
parameters Map<String, ? extends Object> The parameters used to create the geomark.
Return
String The URL to the geomark info resource.

Construct a new new geomark from a string containg a KML, GML, or WKT geometry using the Create Geomark REST API.

The extended parameters to the method are passed in using a Java (map). See the Create Geomark Copy REST API for the list of supported parameters.

The following code fragment shows an example of using the API.


 String baseUrl = "https://apps.gov.bc.ca/pub/geomark";
 GeomarkClient client = new GeomarkClient(baseUrl);

 String geometry = "POLYGON((-112 47,-144 47,-144 60,-112 60,-112 47))";

 Map<String, Object> parameters = new HashMap<String, Object>();
 parameters.put(GeomarkClient.SRID, 4326);
 parameters.put(GeomarkClient.FORMAT, "wkt");

 String geomarkUrl = client.addGeomark(geometry, parameters);
 System.out.println(geomarkUrl);
 
ParameterTypeDescription
geometry String The text of geometry to create the geomark for.
parameters Map<String, ? extends Object> The parameters used to create the geomark.
Return
String The URL to the geomark info resource.

Add the geomarks to the geomark group.

*

The following code fragment shows an example of using the API.


 String baseUrl = "https://apps.gov.bc.ca/pub/geomark";
 GeomarkClient client = new GeomarkClient(baseUrl);
 String geomarkGroupId = "...";
 String geomarkGroupSecretKey = "...";

 Map<String, Object> response = client.addGeomarksToGroup(geomarkGroupId,
   geomarkGroupSecretKey, "gm-abcdefghijklmnopqrstuv0bcislands");
 System.out.println(response);
 
Result Attributes

The method returns a map with the following attributes.

Result Attributes
Name Type Description
status String The status of the request Added, AddedAndNotFound, or NotFound.
geomarkGroupId String The geomark group identifier.
geomarkIds List<String> The list of geomark identifiers that were added to the group.
notFoundGeomarkIds List<String> The list of geomark identifiers that could not be found and were NOT added to the group.
ParameterTypeDescription
geomarkGroupId String The geomark group identifier.
geomarkGroupSecretKey String The geomark group secret key used to sign the request.
geomarkIds Iterable<String> The collection (e.g. List) of geomark URLs or identifiers.
Return
Map<String, Object> The response map.

Add the geomarks to the geomark group.

*

The following code fragment shows an example of using the API.


 String baseUrl = "https://apps.gov.bc.ca/pub/geomark";
 GeomarkClient client = new GeomarkClient(baseUrl);
 String geomarkGroupId = "...";
 String geomarkGroupSecretKey = "...";

 Map<String, Object> response = client.addGeomarksToGroup(geomarkGroupId,
   geomarkGroupSecretKey, "gm-abcdefghijklmnopqrstuv0bcislands");
 System.out.println(response);
 
Result Attributes

The method returns a map with the following attributes.

Result Attributes
Name Type Description
status String The status of the request Added, AddedAndNotFound, or NotFound.
geomarkGroupId String The geomark group identifier.
geomarkIds List<String> The list of geomark identifiers that were added to the group.
notFoundGeomarkIds List<String> The list of geomark identifiers that could not be found and were NOT added to the group.
ParameterTypeDescription
geomarkGroupId String The geomark group identifier.
geomarkGroupSecretKey String The geomark group secret key used to sign the request.
geomarkIds String[] The array of geomark URLs or identifiers.
Return
Map<String, Object> The response map.

Construct a new new geomark by copying the geometries from one or more existing geomarks using the Create Geomark Copy REST API.

The extended parameters to the method are passed in using a Java (map). See the Create Geomark Copy REST API for the list of supported parameters.

The following code fragment shows an example of using the API.


 String baseUrl = "https://apps.gov.bc.ca/pub/geomark";
 GeomarkClient client = new GeomarkClient(baseUrl);
 Map<String, Object> parameters = new HashMap<String, Object>();
 parameter.put(GeomarkClient.BUFFER_METRES, 10);

 List<String> geomarks = Arrays.asList("gm-abcdefghijklmnopqrstuv0bcislands");

 String geomarkUrl = client.copyGeomark(parameters, geomarks);
 
ParameterTypeDescription
parameters Map<String, ? extends Object> The parameters used to create the request.
geomarks Iterable<String> The collection (e.g. List) of geomark URLs or identifiers to create the new geomark from.
Return
String The URL to the geomark info resource.

Construct a new new geomark by copying the geometries from one or more existing geomarks using the Create Geomark Copy REST API.

The extended parameters to the method are passed in using a Java (map). See the Create Geomark Copy REST API for the list of supported parameters.

The following code fragment shows an example of using the API.


 String baseUrl = "https://apps.gov.bc.ca/pub/geomark";
 GeomarkClient client = new GeomarkClient(baseUrl);
 Map<String, Object> parameters = new HashMap<String, Object>();
 parameter.put(GeomarkClient.BUFFER_METRES, 10);

 String geomarkUrl = client.copyGeomark(parameters,
   "gm-abcdefghijklmnopqrstuvwxyz0000bc");
 
ParameterTypeDescription
parameters Map<String, ? extends Object> The parameters used to create the request.
geomarks String[] The array of geomark URLs or identifiers to create the new geomark from.
Return
String The URL to the geomark info resource.

Delete the geomarks from the geomark group.The method does not check if the geomark was a member of the group before deleting, this allows the method to be called multiple times without failure.

*

The following code fragment shows an example of using the API.


 String baseUrl = "https://apps.gov.bc.ca/pub/geomark";
 GeomarkClient client = new GeomarkClient(baseUrl);
 String geomarkGroupId = "...";
 String geomarkGroupSecretKey = "...";

 Map<String, Object> response = client.deleteGeomarksFromGroup(geomarkGroupId,
   geomarkGroupSecretKey, 90, "gm-abcdefghijklmnopqrstuv0bcislands");
 System.out.println(response);
 
Result Attributes

The method returns a map with the following attributes.

Result Attributes
Name Type Description
status String The status of the request Deleted.
geomarkGroupId String The geomark group identifier.
geomarkIds List<String> The list of geomark identifiers that were deleted from the group.
ParameterTypeDescription
geomarkGroupId String The geomark group identifier.
geomarkGroupSecretKey String The geomark group secret key used to sign the request.
expiryDays Integer The number of days from today before the geomark will expire. Can be null to not change the expiry.
geomarkIds Iterable<String> The collection (e.g. List) of geomark URLs or identifiers.
Return
Map<String, Object> The response map.

Delete the geomarks from the geomark group.The method does not check if the geomark was a member of the group before deleting, this allows the method to be called multiple times without failure.

*

The following code fragment shows an example of using the API.


 String baseUrl = "https://apps.gov.bc.ca/pub/geomark";
 GeomarkClient client = new GeomarkClient(baseUrl);
 String geomarkGroupId = "...";
 String geomarkGroupSecretKey = "...";

 Map<String, Object> response = client.deleteGeomarksFromGroup(geomarkGroupId,
   geomarkGroupSecretKey, 90, "gm-abcdefghijklmnopqrstuv0bcislands");
 System.out.println(response);
 
Result Attributes

The method returns a map with the following attributes.

Result Attributes
Name Type Description
status String The status of the request Deleted.
geomarkGroupId String The geomark group identifier.
geomarkIds List<String> The list of geomark identifiers that were deleted from the group.
ParameterTypeDescription
geomarkGroupId String The geomark group identifier.
geomarkGroupSecretKey String The geomark group secret key used to sign the request.
expiryDays Integer The number of days from today before the geomark will expire. Can be null to not change the expiry.
geomarkIds String[] The array of geomark URLs or identifiers.
Return
Map<String, Object> The response map.

Get an InputStream to the geomark bounding box using the Get Geomark Bounding Box REST API.

The caller must close the stream when the resource is downloaded. Use a try/finally block to ensure the stream is closed.

The following code fragment shows an example of using the API.


 String baseUrl = "https://apps.gov.bc.ca/pub/geomark";
 GeomarkClient client = new GeomarkClient(baseUrl);

 String geomarkId = "gm-abcdefghijklmnopqrstuv0bcislands";

 InputStream in = client.getGeomarkBoundingBoxStream(geomarkId, "kml", 4326);
 try {
   // Read the stream
 } finally {
   in.close();
 }
 
ParameterTypeDescription
geomarkId String The geomark URL or identifier.
format String The file extension or MIME media type of the file format for result.
srid Integer The EPSG coordinate system id to use for the geometry.
Return
InputStream An InputStream to the geomark bounding box resource.

Get the URL to the geomark bounding box using the Get Geomark Bounding Box REST API.

The following code fragment shows an example of using the API.


 String baseUrl = "https://apps.gov.bc.ca/pub/geomark";
 GeomarkClient client = new GeomarkClient(baseUrl);

 String geomarkId = "gm-abcdefghijklmnopqrstuv0bcislands";

 String geomarkUrl = client.getGeomarkBoundingBoxUrl(geomarkId, "kml", 4326);
 System.out.println(geomarkUrl);
 
ParameterTypeDescription
geomarkId String The geomark URL or identifier.
format String The file extension or MIME media type of the file format for result.
srid Integer The EPSG coordinate system id to use for the geometry. * @return The URL to the geomark bounding box resource.
Return
String The URL to the geomark bounding box resource.

Get an InputStream to the geomark feature using the Get Geomark Feature REST API.

The caller must close the stream when the resource is downloaded. Use a try/finally block to ensure the stream is closed.

The following code fragment shows an example of using the API.


 String baseUrl = "https://apps.gov.bc.ca/pub/geomark";
 GeomarkClient client = new GeomarkClient(baseUrl);

 String geomarkId = "gm-abcdefghijklmnopqrstuv0bcislands";

 InputStream in = client.getGeomarkFeatureStream(geomarkId, "kml", 4326);
 try {
   // Read the stream
 } finally {
   in.close();
 }
 
ParameterTypeDescription
geomarkId String The geomark URL or identifier.
format String The file extension or MIME media type of the file format for result.
srid Integer The EPSG coordinate system id to use for the geometry.
Return
InputStream An InputStream to the geomark feature resource.

Get the URL to the geomark feature using the Get Geomark Feature REST API.

The following code fragment shows an example of using the API.


 String baseUrl = "https://apps.gov.bc.ca/pub/geomark";
 GeomarkClient client = new GeomarkClient(baseUrl);

 String geomarkId = "gm-abcdefghijklmnopqrstuv0bcislands";

 String geomarkUrl = client.getGeomarkFeatureUrl(geomarkId, "kml", 4326);
 System.out.println(geomarkUrl);
 
ParameterTypeDescription
geomarkId String The geomark URL or identifier.
format String The file extension or MIME media type of the file format for result.
srid Integer The EPSG coordinate system id to use for the geometry.
Return
String The URL to the geomark feature resource.

Get a Map containing the geomark info using the Get Geomark Info REST API.

The following code fragment shows an example of using the API.


 String baseUrl = "https://apps.gov.bc.ca/pub/geomark";
 GeomarkClient client = new GeomarkClient(baseUrl);

 String geomarkId = "gm-abcdefghijklmnopqrstuv0bcislands";

 Map<String, Object> geomark = client.getGeomarkInfo(geomarkId);
 System.out.println(geomark);
 
ParameterTypeDescription
geomarkId String The geomark URL or identifier.
Return
Map<String, Object> The map containing the geomark info properties.

Get an InputStream to the geomark info using the Get Geomark Info REST API.

The caller must close the stream when the resource is downloaded. Use a try/finally block to ensure the stream is closed.

The following code fragment shows an example of using the API.


 String baseUrl = "https://apps.gov.bc.ca/pub/geomark";
 GeomarkClient client = new GeomarkClient(baseUrl);

 String geomarkId = "gm-abcdefghijklmnopqrstuv0bcislands";

 InputStream in = client.getGeomarkInfoStream(geomarkId, "json");
 try {
   // Read the stream
 } finally {
   in.close();
 }
 
ParameterTypeDescription
geomarkId String The geomark URL or identifier.
format String The file extension or MIME media type of the file format for result.
Return
InputStream An InputStream to the geomark info resource.

Get the URL to the geomark info using the Get Geomark Info REST API.

The following code fragment shows an example of using the API.


 String baseUrl = "https://apps.gov.bc.ca/pub/geomark";
 GeomarkClient client = new GeomarkClient(baseUrl);

 String geomarkId = "gm-abcdefghijklmnopqrstuv0bcislands";

 String geomarkUrl = client.getGeomarkInfoUrl(geomarkId, "json");
 System.out.println(geomarkUrl);
 
ParameterTypeDescription
geomarkId String The geomark URL or identifier.
format String The file extension or MIME media type of the file format for result.
Return
String The URL to the geomark info resource.

Get an InputStream to the geomark parts using the Get Geomark Parts REST API.

The caller must close the stream when the resource is downloaded. Use a try/finally block to ensure the stream is closed.

The following code fragment shows an example of using the API.


 String baseUrl = "https://apps.gov.bc.ca/pub/geomark";
 GeomarkClient client = new GeomarkClient(baseUrl);

 String geomarkId = "gm-abcdefghijklmnopqrstuv0bcislands";

 InputStream in = client.getGeomarkPartsStream(geomarkId, "kml", 4326);
 try {
   // Read the stream
 } finally {
   in.close();
 }
 
ParameterTypeDescription
geomarkId String The geomark URL or identifier.
format String The file extension or MIME media type of the file format for result.
srid Integer The EPSG coordinate system id to use for the geometry.
Return
InputStream An InputStream to the geomark parts resource.

Get the URL to the geomark parts using the Get Geomark Parts REST API.

The following code fragment shows an example of using the API.


 String baseUrl = "https://apps.gov.bc.ca/pub/geomark";
 GeomarkClient client = new GeomarkClient(baseUrl);

 String geomarkId = "gm-abcdefghijklmnopqrstuv0bcislands";

 String geomarkUrl = client.getGeomarkPartsUrl(geomarkId, "kml", 4326);
 System.out.println(geomarkUrl);
 
ParameterTypeDescription
geomarkId String The geomark URL or identifier.
format String The file extension or MIME media type of the file format for result.
srid Integer The EPSG coordinate system id to use for the geometry.
Return
String The URL to the geomark parts resource.

Get an InputStream to the geomark point using the Get Geomark Point REST API.

The caller must close the stream when the resource is downloaded. Use a try/finally block to ensure the stream is closed.

The following code fragment shows an example of using the API.


 String baseUrl = "https://apps.gov.bc.ca/pub/geomark";
 GeomarkClient client = new GeomarkClient(baseUrl);

 String geomarkId = "gm-abcdefghijklmnopqrstuv0bcislands";

 InputStream in = client.getGeomarkPointStream(geomarkId, "kml", 4326);
 try {
   // Read the stream
 } finally {
   in.close();
 }
 
ParameterTypeDescription
geomarkId String The geomark URL or identifier.
format String The file extension or MIME media type of the file format for result.
srid Integer The EPSG coordinate system id to use for the geometry.
Return
InputStream An InputStream to the geomark point resource.

Get the URL to the geomark point using the Get Geomark Point REST API.

The following code fragment shows an example of using the API.


 String baseUrl = "https://apps.gov.bc.ca/pub/geomark";
 GeomarkClient client = new GeomarkClient(baseUrl);

 String geomarkId = "gm-abcdefghijklmnopqrstuv0bcislands";

 String geomarkUrl = client.getGeomarkPointUrl(geomarkId, "kml", 4326);
 System.out.println(geomarkUrl);
 
ParameterTypeDescription
geomarkId String The geomark URL or identifier.
format String The file extension or MIME media type of the file format for result.
srid Integer The EPSG coordinate system id to use for the geometry.
Return
String The URL to the geomark point resource.