Use buildings and terrain around you on iOS

The Streetscape Geometry APIs provide the geometry of terrain, buildings, or other structures in a scene. The geometry can be used for occlusion, rendering, or placing AR content via hit-test APIs. Streetscape Geometry data is obtained through Google Street View imagery.

Try the sample

The GeospatialExample app demonstrates how to obtain and render Streetscape Geometries.

Set up the Geospatial API

To use Streetscape Geometry, you'll need to set up the Geospatial API in your project. Follow instructions on Enabling the Geospatial API to set up the Geospatial API.

Enable Streetscape Geometry

The Geospatial API obtains Streetscape Geometry data when the GARGeospatialMode is set to GARGeospatialModeEnabled and GARStreetscapeGeometryMode is set to GARStreetscapeGeometryModeEnabled.

GARSessionConfiguration *configuration = [[GARSessionConfiguration alloc] init];
configuration.geospatialMode = GARGeospatialModeEnabled;
configuration.streetscapeGeometryMode = GARStreetscapeGeometryModeEnabled;
[garSession setConfiguration:configuration error:&error];

Obtain Streetscape Geometry in an ARCore session

Use GARFrame.streetscapeGeometries to obtain all GARStreetscapeGeometry objects.

Understand GARStreetscapeGeometry

GARStreetscapeGeometry contains information about a building:

Building LOD 1

GARStreetscapeGeometryQualityBuildingLOD_1 consists of building footprints extruded upwards to a flat top. Building heights may be inaccurate.

Building LOD 2

GARStreetscapeGeometryQualityBuildingLOD_2 will have higher fidelity geometry. Mesh walls and roofs will more closely match the building's shape. Smaller features like chimneys or roof vents may still poke outside of the mesh.

Understand GARMesh

GARMesh is a polygon mesh representing a surface reconstruction of the Streetscape Geometry. Each GARMesh includes a vertex buffer and index buffer:

Attach AR content to a GARStreetscapeGeometry

Use GARSesssion.createAnchorOnStreetscapeGeometry:transform:error: to create an anchor at a given pose near GARStreetscapeGeometry.meshTransform. This anchor will inherit its tracking state from the parent GARStreetscapeGeometry.

Perform a hit-test against GARStreetscapeGeometry

GARSession.raycastStreetscapeGeometry:direction:error: can be used to hit-test against Streetscape Geometry. If intersections are found, GARStreetscapeGeometryRaycastResult contains pose information about the hit location as well as a reference to the GARStreetscapeGeometry which was hit. This Streetscape Geometry can be passed to GARSesssion.createAnchorOnStreetscapeGeometry:transform:error: to create an anchor attached to it.

NSArray<GARStreetscapeGeometryRaycastResult *> *results =
    [session raycastStreetscapeGeometry:arRaycastQuery.origin
                              direction:arRaycastQuery.direction
                                  error:&error];
[session createAnchorOnStreetscapeGeometry:results[0].streetscapeGeometry
                                 transform:results[0].worldTransform
                                     error:&error];