Receive email notifications by changing your settings.
Click on your picture in the top right corner, go to Preferences and select your notification preferences.
Thank you for contributing to our forum!
Please keep in mind:
1. To only comment on the topic where the discussion is about. Do you have a new question or topic? Please start a new discussion.
2. Be kind to other users!

import buildings through API

Hello,

I am trying to import buildings (trees) through the API, via editorbuilding --> import. To avoid making alot of API calls, I want to import multiple buildings at once, similar to the example at the bottom of the page (https://engine.tygron.com/api/session/event/editorbuilding/import/?token=xx). However, I get a response code 400 with the following message:

'Parameter 0 of event EditorBuildingEventType.IMPORT is of class Polygon. Class GeometryCollection is expected.'

How can I solve this error? When I try to import only one geometry, I don't get an error and the building is imported just fine.

I am using python and I make a list of the geometries (just like in the example).


Thanks in advance,


Kind regards,


Gijs

Tagged:

Comments

  • Hi Gijs,

    without seeing the exact input it is difficult to say precisely what the issue is. The message seems to suggest that, at the very least, the provided json-information of geo data is not recognized as a GeometryCollection. The Event will require the geodata to be of that overarching type, as that is the format which will allow multiple sub-features for import. Perhaps the data is in some way malformed or does not advertise its type properly.

    Is is possible to provide your input (anonymised if so preferred), so the exact structure can be checked?

    Regards!

  • Hi Rudolf,

    I have the GeometryCollection in the right format now, and I am able to add my trees to the project. However, I can only assign one attribute to each tree, while I would like to assign two (height en crown factor). So what I try is to make a list of the attribute couples and attribute values and pass them to the api url, like in the image below. This gives an error:

    'Invalid value of parameter 2 (String[]) for Event: EditorBuildingEventType/IMPORT with parameters: GeometryCollection, String[], String[], double[][], Integer[], Integer[], Double, Integer. Error: Cannot deserialize value of type `java.lang.String` from Array value (token `JsonToken.START_ARRAY`)\n at [Source: (org.glassfish.jersey.message.internal.EntityInputStream); line: 1, column: 492] (through reference chain: java.lang.Object[][0])'


    When I only assign one attribute, it works and the trees are added to my project, see below:

    Is there a way to add both attributes to all trees? Or is there another way to add a secnod attribute to all trees?


    Kind regards,


    Gijs

  • Hi Gijs,

    The list of attribute values must be a matrix, folded into a 1-dimensional list. This means the following:

    • Given a list of 3 features
    • With names provided as ["A","B","C"]
    • And attributes provided as ["X","Y"]
    • And values provided as [1,2,3,4,5, [6,7] ]

    The result will be a feature A, with attribute X=1 and Y=2, a feature B, with attribute X=3 and Y=4, and feature C with attribute X=5 and Y=[6, 7]

  • It is working now, thank you!

Sign In or Register to comment.