How-to guide·Geo referencingJavaScript · Java

Extract a geo reference from an EPSG code or WKT

Derive a geo reference from the coordinates in the model, given the CRS they are in as an EPSG code or a WKT definition, or from IfcSite and IfcMapConversion; nothing is stored until you set it.

Extraction computes a geo reference from what the IFC file contains and returns it; it changes nothing in the repository. When the result is right, store it with Set the geo reference.

Before you start#

You need a client with the gis:read scope, the Vid of a processed version and, for the EPSG and WKT methods, the coordinate reference system the model's IfcSite placement is expressed in. The methods, most reliable first:

Method JavaScript Java Reads
IfcMapConversion (IFC4 and later) extractGeoReferenceFromIfcMapConversion(vid) — The IfcMapConversion with its projected CRS; the recommended method when the model has one.
IfcMapConversion property set (IFC2X3) extractGeoReferenceFromIfcMapConversionPset(vid) — The same information from the property set some IFC2X3 exporters write.
EPSG code extractGeoReferenceUsingEpsg(vid, "EPSG:28992") extractGeoReference(uuid, "EPSG:28992") The x and y of the IfcSite placement, interpreted in the given system.
WKT extractGeoReferenceUsingWkt(vid, wkt) — The same, for a system that is not in the EPSG registry, given as a WKT definition.
IfcSite attributes extractGeoReferenceUsingIfcSite(vid) — RefLatitude, RefLongitude and RefElevation of IfcSite; rarely accurate.

Steps#

  1. Extract. The result is {geo_reference, anchor_point, original_epsg}: the geo reference converted to WGS84 (EPSG:4326), the anchor point in model coordinates and, for the EPSG and map-conversion methods, the code of the system the model was in.

    const factory = new BimWorksClientFactory("https://bim.works");
    const client = await factory.createClientWithApiToken("<your API token>");
    
    const extraction = await client.gis.extractGeoReferenceUsingEpsg("<version uuid of the first demo model>", "EPSG:28992");
    console.log(extraction.geo_reference, extraction.anchor_point, extraction.original_epsg);
    
    // A system outside the EPSG registry
    const wkt = `PROJCS["…", GEOGCS["…", …], PROJECTION["…"], …]`;
    const fromWkt = await client.gis.extractGeoReferenceUsingWkt("<version uuid of the first demo model>", wkt);
    try (BimWorksClientFactory factory = new BimWorksClientFactory("https://bim.works");
         BimWorksClient client = factory.createClientWithApiToken("<your API token>")) {
    	UUID version = UUID.fromString("<version uuid of the first demo model>");
    	GeoReferenceExtraction extraction = client.gis.extractGeoReference(version, "EPSG:28992");
    	System.out.println(extraction.getGeoReference() + " at " + extraction.getAnchorPoint());
    }
  2. Judge the result. Compare geo_reference.latitude and longitude with where the building stands; a model whose IfcSite sits at the local origin comes out at the origin of the projected system, which is the sign that the placement does not hold projected coordinates and another method is needed.

  3. Store it with setGeoReference(vid, extraction.geo_reference, extraction.anchor_point, extraction.original_epsg) (Set the geo reference). In the BIM.works UI the Location section does both in one click (Set a geo reference).

Over HTTP#

ExtractGeoReference takes the method by name: map_conversion, map_conversion_pset, ifc_site, or epsg with an epsg code or a wkt definition. With auto the server chooses: it tries the map conversion, then its property set, then the IfcSite attributes, and answers the first that gives a geo reference, with method saying which one did. The answer has the same geo_reference, anchor_point and original_epsg as above.

POST/openapi/gis/ExtractGeoReferenceExtractGeoReference reference
Authorization
Bearer <auth token>
Content-Type
application/json
Body
1 2 3 4 5
Authorization: Bearer <auth token>
Content-Type: application/json
Accept: application/json
curl -X POST "$BIMWORKS_URL/openapi/gis/ExtractGeoReference" \
  -H "Authorization: Bearer $BIMWORKS_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
  "model": {"type": "VersionModelIdentifier", "uuid": BIM_WORKS_FIRST_MODEL},
  "method": "epsg",
  "epsg": "EPSG:28992"
}'
Send to see the response

Errors#

The EPSG code must start with EPSG:, otherwise the call fails with INVALID_EPSG. A version that has not been processed fails with MODEL_NOT_FOUND. Over HTTP, a method that finds no geo reference, or auto when none of its methods does, fails with NO_GEO_REFERENCE.

Check#

Set the extracted reference, then open the model in the BIM.works Map view: the footprint lies on the site.