jazzband / geojson

Python bindings and utilities for GeoJSON
https://pypi.python.org/pypi/geojson/
BSD 3-Clause "New" or "Revised" License
898 stars 120 forks source link

geojson.utils.generate_random not working correctly for polygon with boundingBox #160

Closed krishnaglodha closed 2 years ago

krishnaglodha commented 3 years ago

I'm trying to send custom values in boundingBox, to generate random geometry. The functions seems to be working correctly for Point and Linestring, but having problem in Polygon

Screenshot 2021-03-19 at 11 56 01 PM Screenshot 2021-03-19 at 11 56 23 PM
Amertz08 commented 3 years ago

I think I might also be having the same issue. We have a db constraint that does not allow certain lat/long points to be crossed. I was hoping to restrict it via the bounding box.

The following error is generated via a db procedure. You can see the point generated.

couldn't project point (54 -91 0): latitude or longitude exceeded limits (-14)

This is the call

generate_random("Polygon", boundingBox=[-14, -14, 14, 14])
rayrrr commented 2 years ago

Hello @krishnaglodha and @Amertz08 I have not been able to reproduce this error. generate_random("Polygon", boundingBox=[-14, -14, 14, 14]) works as expected for me when I run it. If you can provide a code block that reproduces the error I will reopen this issue and investigate.

imanshafiei540 commented 1 year ago

Hey, I'm working with the generate_random function in utils, and it's not working correctly.

python==3.9.2 (also tried with 3.10.8) geojson==2.5.0

from geojson import utils
utils.generate_random(featureType = 'Polygon', boundingBox = [-14, -14, 14, 14], numberVertices=10)

Output: {"coordinates": [[[43, 71], [-2, 34], [-47, 50], [-42, 8], [-64, -26], [-53, -79], [2, -44], [18, -20], [117, -23], [61, 25], [43, 71]]], "type": "Polygon"}

Let me know if you need more information.