Create spaces
When you upload a floorplan file (DXF, DWG, PNG, JPEG, or PDF) using the @gospace-ai/api SDK’s layersUpload method, spaces (e.g., desks) are automatically created within the layer. If you need to add additional spaces or did not use a floorplan upload, you can create spaces manually using the /spatial/v1/spaces endpoint with geometry data in WKT, GeoJSON, or IMDF format.
Create a Script
Create a JavaScript file to create a space with WKT geometry:
// create_space.js
const { GospaceClient } = require('@gospace-ai/api');
require('dotenv').config();
async function createSpace() {
try {
const client = new GospaceClient({ api_key: process.env.GOSPACE_API_KEY || '' });
const space = await client.spatial.spacesCreate({
layer_id: 'lay_67890',
name: 'Desk 101',
type: 'desk',
geometry: {
type: 'WKT',
data: 'POINT (10 10)'
},
labels: ['ergonomic_chair', 'near_window']
});
console.log('Space created:', space.id);
} catch (error) {
console.error('Error creating space:', error);
}
}
createSpace();
Run the Script
Ensure your .env file contains a valid GOSPACE_API_KEY, then run:
node create_space.js
You should see the created space’s ID printed, such as:
Space created: spc_12345
Last updated
Was this helpful?