GisApi
Java SDK: the GIS - Geographic Information Systems operations, 6 methods, each with its parameters, result and a complete example.
Java SDK · nl.bimbase.bimworks.sdk.api · class · 6 methods
GIS related calls, for example to export to CityGML
Construct it with the client of the connect step: new GisApi(client). Each method is one operation of the API part, where it runs on its page.
| Method | Operation | Description |
|---|---|---|
copyGeoReference | CopyGeoReference | Give a Version the georeference of another |
exportCityGML3 | ExportCityGML3 | Export one or more IFC models to CityGML 3 or CityJSON 2 |
extractGeoReference | ExtractGeoReference | Compute a georeference from the model |
generate3DTilesUrl | Generate3DTilesUrl | Create a signed 3D Tiles tileset URL for a folder or a set of versions |
getGeoReference | GetGeoReference | Read or convert a georeference |
setGeoReference | SetGeoReference | Store a Version's georeference |
copyGeoReference#
public CopiedGeoReference copyGeoReference(CopyGeoReferenceRequest copyGeoReferenceRequest) throws ApiExceptionGive a Version the georeference of another. Copies the georeference of from onto model: the latitude, longitude, elevation and rotation, rotation_north and original_epsg as they are, and the anchor point converted to the target's length unit, so it is the same point. A georeference places a Version's aligned coordinates, so a drawing (PDF, DWG) aligned onto an IFC model and given that model's georeference is shown on the earth where the model is: in GEO mode, next to GIS layers, on the map. The answer says where it came from (geo_reference_source, with the target's alignment at the time) and warns when the target has no alignment. Needs write rights on model and read rights on from.
| Operation | CopyGeoReference · POST /openapi/gis/CopyGeoReference |
|---|---|
| Scope | gis:write |
Parameters#
| Name | Type | Description |
|---|---|---|
copyGeoReferenceRequest | CopyGeoReferenceRequestrequired | The request: its properties are those of the model, its JSON that of CopyGeoReference's request body. |
Returns#
CopiedGeoReference — The georeference as stored on model
Example#
import nl.bimbase.bimworks.sdk.api.AuthApi;
import nl.bimbase.bimworks.sdk.api.GisApi;
import nl.bimbase.bimworks.sdk.client.ApiClient;
import nl.bimbase.bimworks.sdk.model.Auth;
import nl.bimbase.bimworks.sdk.model.CopyGeoReferenceRequest;
import nl.bimbase.bimworks.sdk.model.LoginWithApiTokenRequest;
public class Example {
public static void main(String[] args) throws Exception {
// 1. Connect to BIM.works and log in with your API token
ApiClient client = new ApiClient();
client.updateBaseUri("https://bim.works/openapi");
Auth auth = new AuthApi(client)
.loginWithApiToken(new LoginWithApiTokenRequest().token("<your API token>"))
.getAuth();
client.setRequestInterceptor(builder -> builder.setHeader("Authorization", "Bearer " + auth.getBase64()));
// 2. The request
CopyGeoReferenceRequest request = client.getObjectMapper().readValue("""
{
"model": {
"type": "UrlModelIdentifier"
},
"from": {
"type": "UrlModelIdentifier"
}
}
""", CopyGeoReferenceRequest.class);
// 3. The call
var result = new GisApi(client).copyGeoReference(request);
// 4. The result
System.out.println(client.getObjectMapper().writerWithDefaultPrettyPrinter().writeValueAsString(result));
}
}exportCityGML3#
public File exportCityGML3(ExportCityGML3Request exportCityGML3Request) throws ApiExceptionExport one or more IFC models to CityGML 3 or CityJSON 2. Export one or more IFC models into one city model, using per-LOD export settings that select objects and geometry via BQL. format chooses the encoding; it wins over the Accept header, which is only read when format is absent.
| Operation | ExportCityGML3 · POST /openapi/gis/ExportCityGML3 |
|---|---|
| Scope | model:read |
Parameters#
| Name | Type | Description |
|---|---|---|
exportCityGML3Request | ExportCityGML3Requestrequired | The request: its properties are those of the model, its JSON that of ExportCityGML3's request body. |
Returns#
File — The exported city model, in the requested format
Example#
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.StandardCopyOption;
import nl.bimbase.bimworks.sdk.api.AuthApi;
import nl.bimbase.bimworks.sdk.api.GisApi;
import nl.bimbase.bimworks.sdk.client.ApiClient;
import nl.bimbase.bimworks.sdk.model.Auth;
import nl.bimbase.bimworks.sdk.model.ExportCityGML3Request;
import nl.bimbase.bimworks.sdk.model.LoginWithApiTokenRequest;
public class Example {
public static void main(String[] args) throws Exception {
// 1. Connect to BIM.works and log in with your API token
ApiClient client = new ApiClient();
client.updateBaseUri("https://bim.works/openapi");
Auth auth = new AuthApi(client)
.loginWithApiToken(new LoginWithApiTokenRequest().token("<your API token>"))
.getAuth();
client.setRequestInterceptor(builder -> builder.setHeader("Authorization", "Bearer " + auth.getBase64()));
// 2. The request
ExportCityGML3Request request = client.getObjectMapper().readValue("""
{
"models": [
{
"type": "UrlModelIdentifier"
}
],
"settings": {},
"format": "citygml3"
}
""", ExportCityGML3Request.class);
// 3. The call
var result = new GisApi(client).exportCityGML3(request);
// 4. The result
Files.move(result.toPath(), Path.of("export-city-gml3.gml"), StandardCopyOption.REPLACE_EXISTING);
}
}extractGeoReference#
public ExtractedGeoReference extractGeoReference(ExtractGeoReferenceRequest extractGeoReferenceRequest) throws ApiExceptionCompute a georeference from the model. Computes a georeference from what the IFC file says, without storing it: call SetGeoReference with the answer to keep it. method:
| Operation | ExtractGeoReference · POST /openapi/gis/ExtractGeoReference |
|---|---|
| Scope | gis:read |
Parameters#
| Name | Type | Description |
|---|---|---|
extractGeoReferenceRequest | ExtractGeoReferenceRequestrequired | The request: its properties are those of the model, its JSON that of ExtractGeoReference's request body. |
Returns#
ExtractedGeoReference — The georeference that was found
Example#
import nl.bimbase.bimworks.sdk.api.AuthApi;
import nl.bimbase.bimworks.sdk.api.GisApi;
import nl.bimbase.bimworks.sdk.client.ApiClient;
import nl.bimbase.bimworks.sdk.model.Auth;
import nl.bimbase.bimworks.sdk.model.ExtractGeoReferenceRequest;
import nl.bimbase.bimworks.sdk.model.LoginWithApiTokenRequest;
public class Example {
public static void main(String[] args) throws Exception {
// 1. Connect to BIM.works and log in with your API token
ApiClient client = new ApiClient();
client.updateBaseUri("https://bim.works/openapi");
Auth auth = new AuthApi(client)
.loginWithApiToken(new LoginWithApiTokenRequest().token("<your API token>"))
.getAuth();
client.setRequestInterceptor(builder -> builder.setHeader("Authorization", "Bearer " + auth.getBase64()));
// 2. The request
ExtractGeoReferenceRequest request = client.getObjectMapper().readValue("""
{
"model": {
"type": "UrlModelIdentifier"
},
"method": "map_conversion",
"epsg": "",
"wkt": ""
}
""", ExtractGeoReferenceRequest.class);
// 3. The call
var result = new GisApi(client).extractGeoReference(request);
// 4. The result
System.out.println(client.getObjectMapper().writerWithDefaultPrettyPrinter().writeValueAsString(result));
}
}generate3DTilesUrl#
public Generate3DTilesUrl200Response generate3DTilesUrl(Generate3DTilesUrlRequest generate3DTilesUrlRequest) throws ApiExceptionCreate a signed 3D Tiles tileset URL for a folder or a set of versions. Mints a URL to a Cesium 3D Tiles tileset.json of the models of a folder node (followed recursively at request time) or of a fixed set of versions. The settings — which objects, in which colours, with which batch-table columns — are signed into the URL and cannot be changed by whoever holds it. The URL is valid for 90 days.
| Operation | Generate3DTilesUrl · POST /openapi/gis/Generate3DTilesUrl |
|---|---|
| Scope | geometry:read |
Parameters#
| Name | Type | Description |
|---|---|---|
generate3DTilesUrlRequest | Generate3DTilesUrlRequestrequired | The request: its properties are those of the model, its JSON that of Generate3DTilesUrl's request body. |
Returns#
Generate3DTilesUrl200Response — The tileset URL
Example#
import nl.bimbase.bimworks.sdk.api.AuthApi;
import nl.bimbase.bimworks.sdk.api.GisApi;
import nl.bimbase.bimworks.sdk.client.ApiClient;
import nl.bimbase.bimworks.sdk.model.Auth;
import nl.bimbase.bimworks.sdk.model.Generate3DTilesUrlRequest;
import nl.bimbase.bimworks.sdk.model.LoginWithApiTokenRequest;
public class Example {
public static void main(String[] args) throws Exception {
// 1. Connect to BIM.works and log in with your API token
ApiClient client = new ApiClient();
client.updateBaseUri("https://bim.works/openapi");
Auth auth = new AuthApi(client)
.loginWithApiToken(new LoginWithApiTokenRequest().token("<your API token>"))
.getAuth();
client.setRequestInterceptor(builder -> builder.setHeader("Authorization", "Bearer " + auth.getBase64()));
// 2. The request
Generate3DTilesUrlRequest request = client.getObjectMapper().readValue("""
{
"node_uuid": "00000000-0000-0000-0000-000000000000",
"version_uuids": [
"<version uuid of the first demo model>"
],
"settings": {},
"link_account": false
}
""", Generate3DTilesUrlRequest.class);
// 3. The call
var result = new GisApi(client).generate3DTilesUrl(request);
// 4. The result
System.out.println(client.getObjectMapper().writerWithDefaultPrettyPrinter().writeValueAsString(result));
}
}getGeoReference#
public GeoReferenceResult getGeoReference(GetGeoReferenceRequest getGeoReferenceRequest) throws ApiExceptionRead or convert a georeference. With model: the georeference stored on the Version (null when it has none), in target_epsg, with its anchor point in model coordinates, the grid convergence and how its rotation is measured (rotation_north). include_map_conversion adds what the model's own IfcMapConversion says, for a comparison.
| Operation | GetGeoReference · POST /openapi/gis/GetGeoReference |
|---|---|
| Scope | gis:read |
Parameters#
| Name | Type | Description |
|---|---|---|
getGeoReferenceRequest | GetGeoReferenceRequestoptional | The request: its properties are those of the model, its JSON that of GetGeoReference's request body. |
Returns#
GeoReferenceResult — The georeference
Example#
import nl.bimbase.bimworks.sdk.api.AuthApi;
import nl.bimbase.bimworks.sdk.api.GisApi;
import nl.bimbase.bimworks.sdk.client.ApiClient;
import nl.bimbase.bimworks.sdk.model.Auth;
import nl.bimbase.bimworks.sdk.model.GetGeoReferenceRequest;
import nl.bimbase.bimworks.sdk.model.LoginWithApiTokenRequest;
public class Example {
public static void main(String[] args) throws Exception {
// 1. Connect to BIM.works and log in with your API token
ApiClient client = new ApiClient();
client.updateBaseUri("https://bim.works/openapi");
Auth auth = new AuthApi(client)
.loginWithApiToken(new LoginWithApiTokenRequest().token("<your API token>"))
.getAuth();
client.setRequestInterceptor(builder -> builder.setHeader("Authorization", "Bearer " + auth.getBase64()));
// 2. The request
GetGeoReferenceRequest request = client.getObjectMapper().readValue("""
{
"model": {
"type": "UrlModelIdentifier"
},
"geo_reference": {},
"target_epsg": "EPSG:4326",
"include_map_conversion": false,
"include_source": false
}
""", GetGeoReferenceRequest.class);
// 3. The call
var result = new GisApi(client).getGeoReference(request);
// 4. The result
System.out.println(client.getObjectMapper().writerWithDefaultPrettyPrinter().writeValueAsString(result));
}
}setGeoReference#
public void setGeoReference(SetGeoReferenceRequest setGeoReferenceRequest) throws ApiExceptionStore a Version's georeference. Stores where the model is on earth: the georeference (a point in a coordinate system with a rotation) and the anchor point in model coordinates that it applies to. rotation_north says whether the rotation is to grid north (GRID) or true north (TRUE); without it the rotation is to grid north of original_epsg when there is one, else to true north. Needs write rights on the Version. To compute one from the model first, see ExtractGeoReference.
| Operation | SetGeoReference · POST /openapi/gis/SetGeoReference |
|---|---|
| Scope | gis:write |
Parameters#
| Name | Type | Description |
|---|---|---|
setGeoReferenceRequest | SetGeoReferenceRequestrequired | The request: its properties are those of the model, its JSON that of SetGeoReference's request body. |
Returns#
Nothing: the operation answers without a body (Stored).
Example#
import nl.bimbase.bimworks.sdk.api.AuthApi;
import nl.bimbase.bimworks.sdk.api.GisApi;
import nl.bimbase.bimworks.sdk.client.ApiClient;
import nl.bimbase.bimworks.sdk.model.Auth;
import nl.bimbase.bimworks.sdk.model.LoginWithApiTokenRequest;
import nl.bimbase.bimworks.sdk.model.SetGeoReferenceRequest;
public class Example {
public static void main(String[] args) throws Exception {
// 1. Connect to BIM.works and log in with your API token
ApiClient client = new ApiClient();
client.updateBaseUri("https://bim.works/openapi");
Auth auth = new AuthApi(client)
.loginWithApiToken(new LoginWithApiTokenRequest().token("<your API token>"))
.getAuth();
client.setRequestInterceptor(builder -> builder.setHeader("Authorization", "Bearer " + auth.getBase64()));
// 2. The request
SetGeoReferenceRequest request = client.getObjectMapper().readValue("""
{
"model": {
"type": "UrlModelIdentifier"
},
"geo_reference": {},
"anchor_point": {
"x": 0.0,
"y": 0.0,
"z": 0.0
},
"rotation_north": "GRID",
"original_epsg": ""
}
""", SetGeoReferenceRequest.class);
// 3. The call
new GisApi(client).setGeoReference(request);
// 4. The result
// (SetGeoReference answers no content: the call returns once it succeeded and throws an ApiException otherwise)
System.out.println("Done");
}
}