Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug: Error when attempting to insert a geometry<polygon> type in a table. #168

Open
jarodium opened this issue Mar 5, 2025 · 1 comment
Labels
bug Something isn't working

Comments

@jarodium
Copy link

jarodium commented Mar 5, 2025

Describe the bug

When attempting to insert via db.query, I have some strange behaviour when attempting to feed a "geometry" type value.

As reported in surrealdb/surrealdb#5204 (comment) :

Lib\site-packages\surrealdb\data\types\geometry.py", line 66, in parse_coordinates
return GeometryPoint(coordinates[0], coordinates[1])
~~~~~~~~~~~^^^
TypeError: 'GeometryPoint' object is not subscriptable

Printing the coordinates variable yields the following:

[-7.9735981, 37.0497115]
[-7.9758082, 37.0457381]
[-7.9756148, 37.0383393]
[-7.9767212, 37.0314215]
[-7.954491, 37.0309418]
[-7.9550154, 37.0423815]
[-7.964371, 37.0471084]
[-7.9735981, 37.0497115]
GeometryPoint(longitude=-7.9735981, latitude=37.0497115)

Steps to reproduce

  • Have a kml file, from Google Maps with a polygon description.
  • With Python's Shapely (v 2.0.5 ), create a Polygon
coordinates_element = polygon.find('.//kml:coordinates', namespaces={'kml': 'http://www.opengis.net/kml/2.2'})

points = [
    tuple(map(float, point.split(',')[:2]))  # Apenas (lon, lat)
    for point in str(coordinates_element).strip().split()
]

polygon= Polygon(points)
`

- Issue the query: 
```python
record = {
 "polygon" : polygon.__geo_interface__
}

query = f"INSERT INTO {table} {json.dumps(record)};"
`


### Expected behaviour

I am using this in a loop, so I am expecting at least two records inside the table. Only the first is inserted and I have already validated through Surrealist that the is::geometry result is ok and that it renders the schema inside the map.

### SurrealDB version

surreal 2.2.1 for linux on x86_64

### surrealdb.py version

surrealdb.py 1.0.3 for Windows on x64 using Python 3.12.0


### Is there an existing issue for this?

- [x] I have searched the existing issues

### Code of Conduct

- [x] I agree to follow this project's Code of Conduct
@jarodium jarodium added the bug Something isn't working label Mar 5, 2025
@jarodium jarodium changed the title Bug: Bug: Error when attempting to insert a geometry<polygon> type in a table. Mar 5, 2025
@maxwellflitton
Copy link
Contributor

thanks for your issue. I've been working on sorting out some other issues but will get on this today

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants