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
The Geomark Java Client API classes.
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.
Parameter | Type | Description |
---|---|---|
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);
Parameter | Type | Description |
---|---|---|
geometry | InputStream | The text of geometry to create the geomark for. |
parameters | Map<String, ? extends Object> | The parameters used to create the geomark. |
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);
Parameter | Type | Description |
---|---|---|
geometry | String | The text of geometry to create the geomark for. |
parameters | Map<String, ? extends Object> | The parameters used to create the geomark. |
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);
The method returns a map with the following 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. |
Parameter | Type | Description |
---|---|---|
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. |
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);
The method returns a map with the following 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. |
Parameter | Type | Description |
---|---|---|
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. |
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);
Parameter | Type | Description |
---|---|---|
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. |
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");
Parameter | Type | Description |
---|---|---|
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. |
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);
The method returns a map with the following 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. |
Parameter | Type | Description |
---|---|---|
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. |
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);
The method returns a map with the following 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. |
Parameter | Type | Description |
---|---|---|
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. |
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();
}
Parameter | Type | Description |
---|---|---|
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. |
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);
Parameter | Type | Description |
---|---|---|
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. |
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();
}
Parameter | Type | Description |
---|---|---|
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. |
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);
Parameter | Type | Description |
---|---|---|
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. |
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);
Parameter | Type | Description |
---|---|---|
geomarkId | String | The geomark URL or identifier. |
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();
}
Parameter | Type | Description |
---|---|---|
geomarkId | String | The geomark URL or identifier. |
format | String | The file extension or MIME media type of the file format for result. |
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);
Parameter | Type | Description |
---|---|---|
geomarkId | String | The geomark URL or identifier. |
format | String | The file extension or MIME media type of the file format for result. |
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();
}
Parameter | Type | Description |
---|---|---|
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. |
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);
Parameter | Type | Description |
---|---|---|
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. |
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();
}
Parameter | Type | Description |
---|---|---|
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. |
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);
Parameter | Type | Description |
---|---|---|
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. |