Comments (13)
@handlers I got confused, sorry. I meant to point out that if you make a linear_ring first (linear_ring = factory.linear_ring(<array of points>)
) and then pass that linear_ring to the polygon factory, it will return a polygon (factory.polygon(linear_ring)
). Definitely a work around, but it works. I think you can even create the linear_ring from the line_string (factory.linear_ring(line_string)
), but I'll have to double check that in the morning.
from rgeo.
+1 depending on the precision of the provided points, factory.polygon() returns nil
for spherical_factory SRID 4326
This has been open for a long time - Is there any update on when it's going to be fixed?
rgeo (0.3.20)
from rgeo.
Doesn't a polygon require at least 3 distinct points, otherwise it is just a 1-dimensional straight line? Try adding another point before the last, 'closing' point perhaps to make it into a polygon...
a=[factory.point(-92.272935049926986,15.831411705496032)]
=> [#<RGeo::Geographic::SphericalPointImpl:0x15b43d8 "POINT (-92.27293504992699 15.831411705496032)">]
a << factory.point(-92.273079163754431,15.830847348631419)
=> [#<RGeo::Geographic::SphericalPointImpl:0x15b43d8 "POINT (-92.27293504992699 15.831411705496032)">, #<RGeo::Geographic::SphericalPointImpl:0x15cff98 "POINT (-92.27307916375443 15.83084734863142)">]
# Add a NEW point
a << factory.point(-92.27315,15.83001)
=> [#<RGeo::Geographic::SphericalPointImpl:0x15b43d8 "POINT (-92.27293504992699 15.831411705496032)">, #<RGeo::Geographic::SphericalPointImpl:0x15cff98 "POINT (-92.27307916375443 15.83084734863142)">, #<RGeo::Geographic::SphericalPointImpl:0x15e49c0 "POINT (-92.27315 15.83001)">]
# closing point
a << factory.point(-92.272935049926986,15.831411705496032)
=> [#<RGeo::Geographic::SphericalPointImpl:0x15b43d8 "POINT (-92.27293504992699 15.831411705496032)">, #<RGeo::Geographic::SphericalPointImpl:0x15cff98 "POINT (-92.27307916375443 15.83084734863142)">, #<RGeo::Geographic::SphericalPointImpl:0x15e49c0 "POINT (-92.27315 15.83001)">, #<RGeo::Geographic::SphericalPointImpl:0x15eaec4 "POINT (-92.27293504992699 15.831411705496032)">]
linear_ring = factory.linear_ring(a)
=> #<RGeo::Geographic::SphericalLinearRingImpl:0x15ec878 "LINESTRING (-92.27293504992699 15.831411705496032, -92.27307916375443 15.83084734863142, -92.27315 15.83001, -92.27293504992699 15.831411705496032)">
from rgeo.
Cartesian polygon still returns nil. Trying the code on http://blog.daniel-azuma.com/archives/88 results in any polygon being returned as nil.
from rgeo.
If I use a different factory (like the spherical factory), I can create a polygon with the line_string
from rgeo.
I am having the same issue while following the tutorial. My factory object is:
RGeo::Geos::CAPIFactory:0x3fc076578cb4 srid=0 bufres=1 flags=8
Creating a polygon from a linestring returned nil. There is a rescue nil statement in the capi_factory.rb polygon method, but I have no idea why it's being tripped.
from rgeo.
@handlers I was able to get things to work if I made a linear_ring first. Can you gist your code that isn't working?
from rgeo.
@workmaster2n sure thing: https://gist.github.com/handlers/5693967
from rgeo.
@workmaster2n cool -- passing in a linear ring solves the problem for me! I wasn't able to pass a linestring into linear_ring().
from rgeo.
@workmaster2n ya linear_ring solves the problem with charm. author should update the tutorial.
from rgeo.
I found a bug on my side which caused this - hopefully this helps other people:
I had four points which would not be in the right order -- if you connected them by a line, the lines would cross.
#polygon and #linestring just return nil in that case, without any error or explanation.
RGeo should throw an error with a sufficient explanation, or even have code to fix the order
from rgeo.
@tilo is there a way to sort those points?
from rgeo.
Closing this since the spherical factory now raises an error when an invalid linear ring is being initialized.
from rgeo.
Related Issues (20)
- Set Precision for Coordinates HOT 4
- Create Documentation for Adding GEOS Functions to CAPI and FFI Implementations
- C Styleguide
- uby HOT 1
- CAPI stress test under low memory
- Polygon centroid has different SRID
- Concurrency problems with single app-wide factory? HOT 1
- rgeo 3 geom freeze behaviour HOT 3
- Expand classes in `CoordSys` module HOT 1
- Proj Rework: Clean up Core Gem
- Geos not supported HOT 3
- Tackle rubocop todo list HOT 4
- Geos not supported HOT 7
- `test_invalid_polygon_duplicate_rings` test is failing HOT 3
- Add Supported Geos Versions to CI
- `make_valid` throwing errors HOT 1
- RGeo::Error::InvalidGeometry: Unable to cast the geometry to the GEOS Factory HOT 3
- With geos 3.12, the CAPI factory enables Z geometries HOT 6
- RGeo::Geos.supported? false with GEOS 3.12 on Amazon Linux 2023 HOT 21
- `ENVELOPE` method on linestring does not return `POLYGON` HOT 5
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from rgeo.