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

is_simple? Does Not Return False #80

Open
workmaster2n opened this issue Oct 21, 2014 · 3 comments
Open

is_simple? Does Not Return False #80

workmaster2n opened this issue Oct 21, 2014 · 3 comments
Labels

Comments

@workmaster2n
Copy link

A simple polygon does not intersect itself.

points2= [[0,0],[1,1],[1,0],[2,1]]

ring2 = factory.linear_ring( points2.map { |point| factory.point(point[0], point[1])})
polygon2 = factory.polygon(ring2)

polygon2.is_simple? # should be FALSE, returns TRUE

This appears to cause another issue with intersection (from Google Groups: https://groups.google.com/forum/#!topic/rgeo-users/lZNn9T0mbUc)

points = [[13.47252793455753, 290.4766485546728],
  [15.54073426239082, 276.35055725990753],
  [21.90820951900018, 303.537522515156],
  [8.213611305931236, 296.67601244677155],
  [15.856670355018885, 288.5390965152138],
  [5.203107005628723, 282.8149364819326],
  [11.645108176884317, 293.92931144857505],
  [21.47576740464814, 270.17134399422736],
  [29.567834075055067, 295.4682035260122],
  [48.068092286949536, 270.3459504624785],
  [43.03794739858885, 258.13815141284425],
  [55.64874297500046, 280.60030199869936],
  [32.032323591078075, 280.0517447031193],
  [49.87548537467882, 258.4676114262518],
  [59.63260599700384, 277.04500320083656],
  [31.614857616326788, 258.431620967041],
  [53.87189907349915, 265.80523647228813],
  [52.316443015244246, 261.3094217374252],
  [30.37850602489661, 243.96629767610517],
  [37.08920720717105, 252.6877424786614],
  [37.67156320109957, 256.0991612787459],
  [49.7584728112775, 268.3759102823432],
  [59.74319735148887, 264.2208658108574],
  [60.54396507940886, 245.38971341527755],
  [57.564649888497605, 250.08403853549206],
  [39.682138626675425, 259.0749883694973],
  [62.00527379837224, 263.58136799797455],
  [65.05145753546759, 272.02541066609746],
  [83.31572356144625, 254.90296245666315],
  [92.25465895580949, 263.29479945303524],
  [100.81651519586794, 244.4781415919933],
  [97.38250503130493, 243.78791706757247],
  [87.49444190296876, 243.9105261298119],
  [81.82798724390774, 269.6598019646186],
  [80.71955318698129, 260.49555506489577],
  [85.00768677074382, 276.00048670421893],
  [80.10443410251679, 268.8426712207494],
  [91.08764526469497, 271.26692548675146],
  [85.8450963377431, 248.78985255565703],
  [106.03331426082401, 285.6862023617447],
  [81.48185571652127, 276.64182698469585],
  [92.13991556203014, 271.2485875583364],
  [98.38365036214643, 281.45797323863655],
  [102.14553720914083, 278.80697248987985],
  [95.79149025730165, 279.82358453431533],
  [95.38236405117578, 278.8826046839788],
  [79.84595372109368, 285.0388151062105],
  [109.71787571959159, 283.02108741182485],
  [112.05321670679596, 301.5399519356833],
  [96.82862362239786, 272.33343670783256],
  [112.54061379482926, 284.36252505248075],
  [109.06903277165821, 297.19078942883584],
  [75.13325825094185, 308.9704604638807],
  [83.55187277360703, 295.0546419466594],
  [88.84790298938569, 292.9639477216925],
  [75.29244966532377, 295.0210099208458],
  [75.23335443874339, 282.4739464327858],
  [67.91530620904584, 323.50955164491853],
  [63.296053254751605, 298.995544235466],
  [71.80246436883493, 324.3318894704985],
  [64.48794851576415, 309.1294987323138],
  [69.62609875481044, 292.7394221824507],
  [48.95124034776636, 301.7575544233305],
  [84.55514650058575, 303.92593114667574],
  [43.235417508838566, 306.80206762714073],
  [34.73892220880614, 329.1907286303983],
  [52.281451303202594, 301.6084275695357],
  [28.5553253406923, 313.78687528227863],
  [42.59416401736963, 314.44364573586654],
  [33.96574556983046, 331.63047327518854],
  [37.38616713845671, 329.6824866871678],
  [23.131715778639652, 311.4013991985247],
  [15.828757564139648, 323.0965255455127],
  [21.96675393525481, 328.47311769889797],
  [2.9080724237548132, 328.7687465564651],
  [10.505827766014386, 318.71044965218437],
  [21.19898160178375, 333.79701722368725],
  [-1.2563038057836753, 308.56001944644083],
  [16.032524269458786, 313.86497375252344],
  [10.364272681542873, 289.536695054825],
  [12.05479520856448, 297.99725674515264],
  [21.14666849486861, 309.9853339832766],
  [1.3061680539270597, 322.6074468000856],
  [7.3768561576888025, 309.9450393773967],
  [-11.97992962187135, 308.21316177663465]]


ring = factory.linear_ring( points.map { |point| factory.point(point[0], point[1])})

polygon = factory.polygon(ring)
polygon.intersects?(polygon) 

polygon.intersection(polygon) # Should not be nil

I believe is_simple? relies on the GEOS library, so we might have to dig into the wrapper.

@jgandt
Copy link

jgandt commented Oct 30, 2015

I'm still seeing this issue. Any thoughts or movement on it? I have tried to debug, but to no avail thus far.

This renders CAPI unusable for my situation.

@teeparham
Copy link
Member

teeparham commented Jan 2, 2017

is_simple? depends on the factory. I confirmed that is_simple? incorrectly returns true with RGeo::Geos::CAPIFactory for the above test case.

@teeparham teeparham added the bug label Jan 2, 2017
@ronanduddy
Copy link

Hi the FFI and Geographic mercator factories appear to also return true when they are meant to return false:

::RGeo::Geos::FFIFactory.new.parse_wkt('POLYGON ((-73.0 40.0, -73.5 40.0, -73.0 40.5, -73.5 40.5, -73.0 40.0))').is_simple?

::RGeo::Geographic.simple_mercator_factory.parse_wkt('POLYGON ((-73.0 40.0, -73.5 40.0, -73.0 40.5, -73.5 40.5, -73.0 40.0))').is_simple?

Image below of the example polygon.

screen shot 2018-05-08 at 12 09 25

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants