rgeo/activerecord-postgis-adapter

Can't create a polygon

Closed this issue · 9 comments

Neighbourhood.create({name: 'Etobicoke', polygon: 'POLYGON((43.7124970905 -79.53828537340002, 43.7095190905 -79.53897201090001, 43.7080300621 -79.5362254689, 43.7045554558 -79.53622546589997, 43.7045554348 -79.53485216989998, 43.7050518352 -79.5334788449, 43.704927747941 -79.53178373272601, 43.704617477711 -79.53087173490599, 43.704059050675 -79.53008853564398, 43.703469584266 -79.52923021897197, 43.702631942276 -79.52877963366097, 43.699839609278 -79.52150547379, 43.699281128325 -79.52090466197899, 43.698629576113 -79.52075445041203, 43.69800903083 -79.52017511614201, 43.697248831275 -79.519252430253, 43.696892043448 -79.51783621590499, 43.696814471049 -79.516763346782, 43.696954098432 -79.51558316136402, 43.69720231307 -79.51386654255998, 43.697109206 -79.51219283609998, 43.696531282884 -79.51189782102898, 43.695270723381 -79.512675696163, 43.693699902237 -79.51317458017002, 43.692097997109 -79.513458842739, 43.690022715506 -79.51290624857802, 43.68845945802 -79.51267555785802, 43.687516844864 -79.51175821921402, 43.686605241281 -79.51191381094998, 43.68432435573685 -79.51040115755188, 43.682834695525 -79.50948916389098, 43.682493308695 -79.50899568219597, 43.682400217429 -79.50837337751, 43.682400187429 -79.50695718016499, 43.6822411476 -79.50586285221101, 43.68102683131 -79.505455177079, 43.680371149165 -79.50564827073401, 43.679436167733 -79.50712882653102, 43.676627351523 -79.50860943589498, 43.675711674439 -79.50974667147801, 43.674617552564 -79.51196758170698, 43.673977353851 -79.51230553969503, 43.673275045555 -79.512600564259, 43.671754092859 -79.51212849509102, 43.667947569188 -79.511409650063, 43.667400420294 -79.51212847336001, 43.666647632634 -79.51313698565798, 43.664559848464 -79.51299751525602, 43.663469428162 -79.51264883738901, 43.66253422668 -79.51217140242801, 43.661967618875 -79.51104486438999, 43.662021949356 -79.50970377015801, 43.662895120912 -79.507279062375, 43.663085277478 -79.50609890365098, 43.661878369548 -79.50401201694797, 43.660919812164 -79.50271918147303, 43.660019468407 -79.50138882024703, 43.659577017052 -79.50051446907003, 43.659111291487 -79.49971520081101, 43.658249661786 -79.49936124703697, 43.657227032856 -79.49992183166603, 43.656507096372 -79.50108325508398, 43.65516616523 -79.502566504561, 43.654324912211 -79.503098871173, 43.653413840521 -79.50308407428702, 43.652699689401 -79.502477867533, 43.652148493514 -79.50106701197899, 43.651853526556 -79.49845995800001, 43.651775912076 -79.497741120775, 43.651931172331 -79.495370060798, 43.65210969734 -79.49378219105398, 43.652059257969 -79.493009712341, 43.6519155961 -79.49228012039998, 43.651201433846 -79.49155058236698, 43.6504251294 -79.491121434121, 43.649881705151 -79.49106780206102, 43.649431475563 -79.49144327777998, 43.6484377708 -79.49215140436701, 43.6484377538 -79.49228015440002, 43.6464503366 -79.49245181577703, 43.645549727521 -79.49230159689, 43.644695739264 -79.49187243762998, 43.643562233702 -79.49107849979902, 43.642793616877 -79.49079955691599, 43.642087069577016 -79.49055279081045, 43.64135726023737 -79.49002706058559, 43.64105833064962 -79.48976957798357, 43.640939910896 -79.48928140637202, 43.641124316418 -79.4888469069, 43.6418619552974 -79.486025218767, 43.6415047523035 -79.48544589380788, 43.64140769734659 -79.48643292344957, 43.641025309215046 -79.48746288007334, 43.63992083712102 -79.48705517266518, 43.639641318774 -79.48567651509597, 43.63932495221 -79.485439157092, 43.638822167712 -79.48537344152999, 43.638466977341 -79.48517896474499, 43.638235993408 -79.48498451285798, 43.637940924756 -79.484094044941, 43.637770108711 -79.483160614751, 43.637924929284104 -79.47838882979033, 43.63758316692303 -79.47752847746801, 43.63686869536204 -79.47709727858802, 43.63602985954201 -79.47683569564754, 43.63613454907833 -79.47703711332775, 43.636347946092776 -79.47717415799167, 43.637349328134455 -79.47761990869651, 43.637659643044714 -79.47794764220464, 43.63770595881906 -79.47870452915521, 43.63745640090512 -79.47928590233579, 43.63646918951288 -79.47785025433711, 43.635031593823 -79.476865217453, 43.63442919656 -79.476379127092, 43.63363818545 -79.475836592203, 43.63332338158 -79.47536817899498, 43.632489924072 -79.47436298918399, 43.63288595231111 -79.47368171809359, 43.630890238929 -79.47065080292998, 43.629608871666 -79.47235684049497, 43.629321513581 -79.47389115639402, 43.626921815437 -79.47555415654801, 43.623547414882 -79.47647139299698, 43.623568809812 -79.47761657284502, 43.622658221342 -79.47833263148698, 43.622122293699 -79.47975434916799, 43.622456208644 -79.48117603807299, 43.620763010976 -79.48264607365599, 43.6192717322 -79.48119227824799, 43.617159041553 -79.48505992018397, 43.613990057944 -79.48592865344597, 43.610795465074 -79.48640643887302, 43.607725133003 -79.48774242771799, 43.602065449346 -79.49285951453902, 43.602174248652 -79.49432132888, 43.602300495352964 -79.49473169402506, 43.602007203105 -79.49604328139901, 43.60186152264387 -79.49644159507682, 43.600923368051 -79.497269062197, 43.59960641743671 -79.49817563006616, 43.598631305676 -79.49775182226398, 43.59794951063919 -79.49859943441055, 43.597531883013 -79.49959725026201, 43.5951348819 -79.50064872383098, 43.594289874029 -79.50292323616497, 43.59428408102 -79.50494023709501, 43.593433202409 -79.50588428648302, 43.594148085681 -79.50650657286201, 43.593743981444 -79.51064790877001, 43.592205433636 -79.515497348645, 43.590324934542 -79.51517547260102, 43.590402664926 -79.51799714513197, 43.59068829729997 -79.51864897345962, 43.590305645556 -79.51979432824601, 43.589913201003 -79.52499246711898, 43.589481909711 -79.527830246046, 43.588079152935 -79.52949848566101, 43.588599792716 -79.53049625940702, 43.588164654539 -79.53351103440798, 43.588036425358 -79.53432646299399, 43.588234573929 -79.536729704187, 43.586775528694 -79.53917872931402, 43.585098842542 -79.540812228564, 43.583460964733 -79.54229543851, 43.58121690655 -79.543413779074, 43.581768695927 -79.54420226958803, 43.58388651273193 -79.54603961170426, 43.586657043071 -79.548499226312, 43.586657030071 -79.54849924031203, 43.586812454750294 -79.5485314268202, 43.58827341413133 -79.54719032532762, 43.590045222155 -79.549100076223, 43.59054639791869 -79.54929317811246, 43.59225495692308 -79.54954262428356, 43.59474926208385 -79.54992884553195, 43.595298019087366 -79.55473269509162, 43.59825839960483 -79.55407821100272, 43.59921406665876 -79.55473265722321, 43.5999754874546 -79.55531203731164, 43.60124187868696 -79.55615962427157, 43.60522355129305 -79.5620979897131, 43.60699195203553 -79.56469571326886, 43.60767120729744 -79.56574382057175, 43.60867672860034 -79.56782189613648, 43.609896344194 -79.56732834692599, 43.61064985301 -79.56721033448798, 43.610913989199 -79.56666318487999, 43.611613112362 -79.565944348757, 43.611807298685 -79.56508604081603, 43.612219013603 -79.56427064378897, 43.612358827884 -79.56395948051397, 43.612653977123 -79.56382000998701, 43.613182234378 -79.564206266403, 43.613399734713 -79.56472125943799, 43.613453115509 -79.56534484286601, 43.613351197144 -79.56614011909801, 43.613457972328 -79.56687237429298, 43.613858008984 -79.56790766987103, 43.614347394702 -79.56834760409498, 43.615912522972 -79.56792918568999, 43.616275621922 -79.56778435947501, 43.616669822531 -79.56785410050901, 43.617024190982 -79.56756441219397, 43.617254304684 -79.56697436140303, 43.617683474957 -79.56665246900502, 43.618138800728 -79.56660953240299, 43.618780565573 -79.566824114432, 43.61938060701 -79.56678119795401, 43.620933980493 -79.56689922233, 43.62117472807 -79.56609989220397, 43.621403877158 -79.565657363328, 43.621627150711 -79.56556482442801, 43.62166403563 -79.56555808600103, 43.622487299168 -79.56595507771397, 43.6235902145 -79.56575122970003, 43.624413440627 -79.56546152862597, 43.624599826676 -79.56512893022398, 43.624387197442 -79.564388675766, 43.624428466987 -79.564082874755, 43.624625032935 -79.56377712153301, 43.625116244265 -79.56360546328199, 43.625731762203 -79.563669841295, 43.626207428988 -79.56343380203401, 43.626781198143 -79.56358477869799, 43.6275665158 -79.5657512047, 43.6275665028 -79.5671245158, 43.6265724666 -79.56918444230001, 43.6265724476 -79.5705577073, 43.625081333 -79.57467762329998, 43.62508135 -79.57467760629999, 43.6265724676 -79.5801707874, 43.6290575407 -79.58635056899999, 43.637506083967 -79.58635056599996, 43.6375060933 -79.58635057999999, 43.637506105274 -79.58635056599996, 43.637506092809 -79.58635056599996, 43.641481465 -79.58841052150001, 43.6429721657 -79.5911570765, 43.6439659656 -79.59253036749999, 43.6424753146 -79.59733691510002, 43.6444628304 -79.6076365797, 43.6459534671 -79.60900989570001, 43.6643348391 -79.589097149, 43.668805104037 -79.59115709873402, 43.6688051007 -79.59115710949999, 43.6688051037 -79.59115711449999, 43.7025698822 -79.61038316169999, 43.736315648 -79.62960926099998, 43.7442530476 -79.6344157355, 43.749213427 -79.63853565459999, 43.7576450694 -79.60214342569998, 43.757645049684 -79.60214341614903, 43.7626043109 -79.58017076839997, 43.7621083934 -79.5787974804, 43.760620647 -79.57948413489999, 43.760124738 -79.58017078440002, 43.7591328637 -79.5808574239, 43.7586369343 -79.58291734739998, 43.7571490927 -79.58497727700001, 43.755661224 -79.5842906515, 43.7531814034 -79.58291733739998, 43.7502054018 -79.57330431830002, 43.7487174035 -79.57261763880001, 43.7472293082 -79.57261765779998, 43.7467332832 -79.57124439180001, 43.746237234347 -79.568497886145, 43.7462372461 -79.56849780480002, 43.7442530306 -79.56231800519998, 43.7427648643 -79.56163134769997, 43.7407805848 -79.5630046137, 43.7397883718 -79.56025802470003, 43.7397883848 -79.55888476370001, 43.7412766261 -79.55751148159999, 43.74226880840002 -79.55678190074798, 43.7432609362 -79.55407821810002, 43.74350894459349 -79.55167497886958, 43.7422688134 -79.54927169360002, 43.7412766321 -79.54789840249998, 43.7397884048 -79.54652512849998, 43.7392922802 -79.547211758, 43.7378039976 -79.54927173760001, 43.73631565 -79.55064499759999, 43.7358194926 -79.54927173060003, 43.7328426987 -79.5492716956, 43.732842671937 -79.54927171041498, 43.7318503763 -79.54652511149999, 43.7323465536 -79.54446520300002, 43.7303618837 -79.54377856450003, 43.7293695411 -79.54171859899998, 43.7303618877 -79.53965868540001, 43.7318503803 -79.53965866940001, 43.7318504013 -79.53897204790002, 43.7268885962 -79.53828540540002, 43.725896207 -79.54103196049999, 43.7224226096 -79.54034531899998, 43.7204376699 -79.54240524649998, 43.7169637699 -79.543091919, 43.7144823132 -79.53828538139999, 43.712497083963 -79.53828539940002, 43.7124970905 -79.53828537340002))'})

polygon ends up being nil;

#<Neighbourhood id: 72, name: "Etobicoke", polygon: nil, created_at: "2016-10-12 03:03:00", updated_at: "2016-10-12 03:03:00">

I have tested the syntax directly in psql and it seems to work:

SELECT ST_AsGeoJSON('POLYGON((43.7124970905 -79.53828537340002, 43.7095190905 -79.53897201090001, 43.7080300621 -79.5362254689, 43.7045554558 -79.53622546589997, 43.7045554348 -79.53485216989998, 43.7050518352 -79.5334788449 , 43.704927747941 -79.53178373272601, 43.704617477711 -79.53087173490599, 43.704059050675 -79.53008853564398, 43.703469584266 -79.52923021897197, 43.702631942276 -79.52877963366097, 43.699839609278 -79.52150547379, 43.699281128325 -79.52 090466197899, 43.698629576113 -79.52075445041203, 43.69800903083 -79.52017511614201, 43.697248831275 -79.519252430253, 43.696892043448 -79.51783621590499, 43.696814471049 -79.516763346782, 43.696954098432 -79.51558316136402, 43.697202313 07 -79.51386654255998, 43.697109206 -79.51219283609998, 43.696531282884 -79.51189782102898, 43.695270723381 -79.512675696163, 43.693699902237 -79.51317458017002, 43.692097997109 -79.513458842739, 43.690022715506 -79.51290624857802, 43.68 845945802 -79.51267555785802, 43.687516844864 -79.51175821921402, 43.686605241281 -79.51191381094998, 43.68432435573685 -79.51040115755188, 43.682834695525 -79.50948916389098, 43.682493308695 -79.50899568219597, 43.682400217429 -79.50837 337751, 43.682400187429 -79.50695718016499, 43.6822411476 -79.50586285221101, 43.68102683131 -79.505455177079, 43.680371149165 -79.50564827073401, 43.679436167733 -79.50712882653102, 43.676627351523 -79.50860943589498, 43.675711674439 -7 9.50974667147801, 43.674617552564 -79.51196758170698, 43.673977353851 -79.51230553969503, 43.673275045555 -79.512600564259, 43.671754092859 -79.51212849509102, 43.667947569188 -79.511409650063, 43.667400420294 -79.51212847336001, 43.6666 47632634 -79.51313698565798, 43.664559848464 -79.51299751525602, 43.663469428162 -79.51264883738901, 43.66253422668 -79.51217140242801, 43.661967618875 -79.51104486438999, 43.662021949356 -79.50970377015801, 43.662895120912 -79.507279062 375, 43.663085277478 -79.50609890365098, 43.661878369548 -79.50401201694797, 43.660919812164 -79.50271918147303, 43.660019468407 -79.50138882024703, 43.659577017052 -79.50051446907003, 43.659111291487 -79.49971520081101, 43.658249661786
-79.49936124703697, 43.657227032856 -79.49992183166603, 43.656507096372 -79.50108325508398, 43.65516616523 -79.502566504561, 43.654324912211 -79.503098871173, 43.653413840521 -79.50308407428702, 43.652699689401 -79.502477867533, 43.65214 8493514 -79.50106701197899, 43.651853526556 -79.49845995800001, 43.651775912076 -79.497741120775, 43.651931172331 -79.495370060798, 43.65210969734 -79.49378219105398, 43.652059257969 -79.493009712341, 43.6519155961 -79.49228012039998, 43 .651201433846 -79.49155058236698, 43.6504251294 -79.491121434121, 43.649881705151 -79.49106780206102, 43.649431475563 -79.49144327777998, 43.6484377708 -79.49215140436701, 43.6484377538 -79.49228015440002, 43.6464503366 -79.4924518157770 3, 43.645549727521 -79.49230159689, 43.644695739264 -79.49187243762998, 43.643562233702 -79.49107849979902, 43.642793616877 -79.49079955691599, 43.642087069577016 -79.49055279081045, 43.64135726023737 -79.49002706058559, 43.6410583306496 2 -79.48976957798357, 43.640939910896 -79.48928140637202, 43.641124316418 -79.4888469069, 43.6418619552974 -79.486025218767, 43.6415047523035 -79.48544589380788, 43.64140769734659 -79.48643292344957, 43.641025309215046 -79.48746288007334 , 43.63992083712102 -79.48705517266518, 43.639641318774 -79.48567651509597, 43.63932495221 -79.485439157092, 43.638822167712 -79.48537344152999, 43.638466977341 -79.48517896474499, 43.638235993408 -79.48498451285798, 43.637940924756 -79. 484094044941, 43.637770108711 -79.483160614751, 43.637924929284104 -79.47838882979033, 43.63758316692303 -79.47752847746801, 43.63686869536204 -79.47709727858802, 43.63602985954201 -79.47683569564754, 43.63613454907833 -79.47703711332775 , 43.636347946092776 -79.47717415799167, 43.637349328134455 -79.47761990869651, 43.637659643044714 -79.47794764220464, 43.63770595881906 -79.47870452915521, 43.63745640090512 -79.47928590233579, 43.63646918951288 -79.47785025433711, 43.6 35031593823 -79.476865217453, 43.63442919656 -79.476379127092, 43.63363818545 -79.475836592203, 43.63332338158 -79.47536817899498, 43.632489924072 -79.47436298918399, 43.63288595231111 -79.47368171809359, 43.630890238929 -79.470650802929 98, 43.629608871666 -79.47235684049497, 43.629321513581 -79.47389115639402, 43.626921815437 -79.47555415654801, 43.623547414882 -79.47647139299698, 43.623568809812 -79.47761657284502, 43.622658221342 -79.47833263148698, 43.622122293699 - 79.47975434916799, 43.622456208644 -79.48117603807299, 43.620763010976 -79.48264607365599, 43.6192717322 -79.48119227824799, 43.617159041553 -79.48505992018397, 43.613990057944 -79.48592865344597, 43.610795465074 -79.48640643887302, 43.6 07725133003 -79.48774242771799, 43.602065449346 -79.49285951453902, 43.602174248652 -79.49432132888, 43.602300495352964 -79.49473169402506, 43.602007203105 -79.49604328139901, 43.60186152264387 -79.49644159507682, 43.600923368051 -79.497 269062197, 43.59960641743671 -79.49817563006616, 43.598631305676 -79.49775182226398, 43.59794951063919 -79.49859943441055, 43.597531883013 -79.49959725026201, 43.5951348819 -79.50064872383098, 43.594289874029 -79.50292323616497, 43.59428 408102 -79.50494023709501, 43.593433202409 -79.50588428648302, 43.594148085681 -79.50650657286201, 43.593743981444 -79.51064790877001, 43.592205433636 -79.515497348645, 43.590324934542 -79.51517547260102, 43.590402664926 -79.517997145131 97, 43.59068829729997 -79.51864897345962, 43.590305645556 -79.51979432824601, 43.589913201003 -79.52499246711898, 43.589481909711 -79.527830246046, 43.588079152935 -79.52949848566101, 43.588599792716 -79.53049625940702, 43.588164654539 - 79.53351103440798, 43.588036425358 -79.53432646299399, 43.588234573929 -79.536729704187, 43.586775528694 -79.53917872931402, 43.585098842542 -79.540812228564, 43.583460964733 -79.54229543851, 43.58121690655 -79.543413779074, 43.581768695 927 -79.54420226958803, 43.58388651273193 -79.54603961170426, 43.586657043071 -79.548499226312, 43.586657030071 -79.54849924031203, 43.586812454750294 -79.5485314268202, 43.58827341413133 -79.54719032532762, 43.590045222155 -79.549100076 223, 43.59054639791869 -79.54929317811246, 43.59225495692308 -79.54954262428356, 43.59474926208385 -79.54992884553195, 43.595298019087366 -79.55473269509162, 43.59825839960483 -79.55407821100272, 43.59921406665876 -79.55473265722321, 43. 5999754874546 -79.55531203731164, 43.60124187868696 -79.55615962427157, 43.60522355129305 -79.5620979897131, 43.60699195203553 -79.56469571326886, 43.60767120729744 -79.56574382057175, 43.60867672860034 -79.56782189613648, 43.60989634419 4 -79.56732834692599, 43.61064985301 -79.56721033448798, 43.610913989199 -79.56666318487999, 43.611613112362 -79.565944348757, 43.611807298685 -79.56508604081603, 43.612219013603 -79.56427064378897, 43.612358827884 -79.56395948051397, 43 .612653977123 -79.56382000998701, 43.613182234378 -79.564206266403, 43.613399734713 -79.56472125943799, 43.613453115509 -79.56534484286601, 43.613351197144 -79.56614011909801, 43.613457972328 -79.56687237429298, 43.613858008984 -79.56790 766987103, 43.614347394702 -79.56834760409498, 43.615912522972 -79.56792918568999, 43.616275621922 -79.56778435947501, 43.616669822531 -79.56785410050901, 43.617024190982 -79.56756441219397, 43.617254304684 -79.56697436140303, 43.6176834 74957 -79.56665246900502, 43.618138800728 -79.56660953240299, 43.618780565573 -79.566824114432, 43.61938060701 -79.56678119795401, 43.620933980493 -79.56689922233, 43.62117472807 -79.56609989220397, 43.621403877158 -79.565657363328, 43.6 21627150711 -79.56556482442801, 43.62166403563 -79.56555808600103, 43.622487299168 -79.56595507771397, 43.6235902145 -79.56575122970003, 43.624413440627 -79.56546152862597, 43.624599826676 -79.56512893022398, 43.624387197442 -79.56438867 5766, 43.624428466987 -79.564082874755, 43.624625032935 -79.56377712153301, 43.625116244265 -79.56360546328199, 43.625731762203 -79.563669841295, 43.626207428988 -79.56343380203401, 43.626781198143 -79.56358477869799, 43.6275665158 -79.5 657512047, 43.6275665028 -79.5671245158, 43.6265724666 -79.56918444230001, 43.6265724476 -79.5705577073, 43.625081333 -79.57467762329998, 43.62508135 -79.57467760629999, 43.6265724676 -79.5801707874, 43.6290575407 -79.58635056899999, 43. 637506083967 -79.58635056599996, 43.6375060933 -79.58635057999999, 43.637506105274 -79.58635056599996, 43.637506092809 -79.58635056599996, 43.641481465 -79.58841052150001, 43.6429721657 -79.5911570765, 43.6439659656 -79.59253036749999, 4 3.6424753146 -79.59733691510002, 43.6444628304 -79.6076365797, 43.6459534671 -79.60900989570001, 43.6643348391 -79.589097149, 43.668805104037 -79.59115709873402, 43.6688051007 -79.59115710949999, 43.6688051037 -79.59115711449999, 43.7025 698822 -79.61038316169999, 43.736315648 -79.62960926099998, 43.7442530476 -79.6344157355, 43.749213427 -79.63853565459999, 43.7576450694 -79.60214342569998, 43.757645049684 -79.60214341614903, 43.7626043109 -79.58017076839997, 43.7621083 934 -79.5787974804, 43.760620647 -79.57948413489999, 43.760124738 -79.58017078440002, 43.7591328637 -79.5808574239, 43.7586369343 -79.58291734739998, 43.7571490927 -79.58497727700001, 43.755661224 -79.5842906515, 43.7531814034 -79.582917 33739998, 43.7502054018 -79.57330431830002, 43.7487174035 -79.57261763880001, 43.7472293082 -79.57261765779998, 43.7467332832 -79.57124439180001, 43.746237234347 -79.568497886145, 43.7462372461 -79.56849780480002, 43.7442530306 -79.56231 800519998, 43.7427648643 -79.56163134769997, 43.7407805848 -79.5630046137, 43.7397883718 -79.56025802470003, 43.7397883848 -79.55888476370001, 43.7412766261 -79.55751148159999, 43.74226880840002 -79.55678190074798, 43.7432609362 -79.5540 7821810002, 43.74350894459349 -79.55167497886958, 43.7422688134 -79.54927169360002, 43.7412766321 -79.54789840249998, 43.7397884048 -79.54652512849998, 43.7392922802 -79.547211758, 43.7378039976 -79.54927173760001, 43.73631565 -79.550644 99759999, 43.7358194926 -79.54927173060003, 43.7328426987 -79.5492716956, 43.732842671937 -79.54927171041498, 43.7318503763 -79.54652511149999, 43.7323465536 -79.54446520300002, 43.7303618837 -79.54377856450003, 43.7293695411 -79.5417185 9899998, 43.7303618877 -79.53965868540001, 43.7318503803 -79.53965866940001, 43.7318504013 -79.53897204790002, 43.7268885962 -79.53828540540002, 43.725896207 -79.54103196049999, 43.7224226096 -79.54034531899998, 43.7204376699 -79.5424052 4649998, 43.7169637699 -79.543091919, 43.7144823132 -79.53828538139999, 43.712497083963 -79.53828539940002, 43.7124970905 -79.53828537340002))');

No syntax errors. Result: http://bl.ocks.org/d/86fd2eaf2ee1528d865eb47c05c37784

Does anybody know why this doesn't work with postgis adapter?

  • activerecord-postgis-adapter 4.0.0
  • Rails 5.0.1 and Ruby 2.3.0p0
  • pg (0.19.0)
  • PostgreSQL 9.3.14 on x86_64-unknown-linux-gnu, compiled by gcc (Ubuntu 4.8.4-2ubuntu1~14.04.3) 4.8.4, 64-bit
  • POSTGIS="2.2.2 r14797" GEOS="3.5.0-CAPI-1.9.0 r4084" PROJ="Rel. 4.8.0, 6 March 2012" GDAL="GDAL 2.1.0, released 2016/04/25" LIBXML="2.9.1" LIBJSON="0.11.99" RASTER

An Update:

Apparently the Polygon was invalid when I checked it with IsValidDetail(), so I corrected it with MakeValid() function.

I then ensured that there are no repeating points, and that the opening point is identical to the closing point.

But sadly it still wouldn't accept the polygon

Neighbourhood.create({name: 'Etobicoke', polygon: 'POLYGON((43.6375061014461 -79.5863505704755, 43.6375060933 -79.58635058, 43.637506083967 -79.586350566, 43.6290575407 -79.586350569, 43.6265724676 -79.5801707874, 43.62508135 -79.5746776063, 43.625081333 -79.5746776233, 43.6265724476 -79.5705577073, 43.6265724666 -79.5691844423, 43.6275665028 -79.5671245158, 43.6275665158 -79.5657512047, 43.626781198143 -79.563584778698, 43.626207428988 -79.563433802034, 43.625731762203 -79.563669841295, 43.625116244265 -79.563605463282, 43.624625032935 -79.563777121533, 43.624428466987 -79.564082874755, 43.624387197442 -79.564388675766, 43.624599826676 -79.565128930224, 43.624413440627 -79.565461528626, 43.6235902145 -79.5657512297, 43.622487299168 -79.565955077714, 43.62166403563 -79.565558086001, 43.621627150711 -79.565564824428, 43.621403877158 -79.565657363328, 43.62117472807 -79.566099892204, 43.620933980493 -79.56689922233, 43.61938060701 -79.566781197954, 43.618780565573 -79.566824114432, 43.618138800728 -79.566609532403, 43.617683474957 -79.566652469005, 43.617254304684 -79.566974361403, 43.617024190982 -79.567564412194, 43.616669822531 -79.567854100509, 43.616275621922 -79.567784359475, 43.615912522972 -79.56792918569, 43.614347394702 -79.568347604095, 43.613858008984 -79.567907669871, 43.613457972328 -79.566872374293, 43.613351197144 -79.566140119098, 43.613453115509 -79.565344842866, 43.613399734713 -79.564721259438, 43.613182234378 -79.564206266403, 43.612653977123 -79.563820009987, 43.612358827884 -79.563959480514, 43.612219013603 -79.564270643789, 43.611807298685 -79.565086040816, 43.611613112362 -79.565944348757, 43.610913989199 -79.56666318488, 43.61064985301 -79.567210334488, 43.609896344194 -79.567328346926, 43.6086767286003 -79.5678218961365, 43.6076712072974 -79.5657438205718, 43.6069919520355 -79.5646957132689, 43.6052235512931 -79.5620979897131, 43.601241878687 -79.5561596242716, 43.5999754874546 -79.5553120373116, 43.5992140666588 -79.5547326572232, 43.5982583996048 -79.5540782110027, 43.5952980190874 -79.5547326950916, 43.5947492620839 -79.549928845532, 43.5922549569231 -79.5495426242836, 43.5905463979187 -79.5492931781125, 43.590045222155 -79.549100076223, 43.5882734141313 -79.5471903253276, 43.5868124547503 -79.5485314268202, 43.586657030071 -79.548499240312, 43.586657043071 -79.548499226312, 43.5838865127319 -79.5460396117043, 43.581768695927 -79.544202269588, 43.58121690655 -79.543413779074, 43.583460964733 -79.54229543851, 43.585098842542 -79.540812228564, 43.586775528694 -79.539178729314, 43.588234573929 -79.536729704187, 43.588036425358 -79.534326462994, 43.588164654539 -79.533511034408, 43.588599792716 -79.530496259407, 43.588079152935 -79.529498485661, 43.589481909711 -79.527830246046, 43.589913201003 -79.524992467119, 43.590305645556 -79.519794328246, 43.5906882973 -79.5186489734596, 43.590402664926 -79.517997145132, 43.590324934542 -79.515175472601, 43.592205433636 -79.515497348645, 43.593743981444 -79.51064790877, 43.594148085681 -79.506506572862, 43.593433202409 -79.505884286483, 43.59428408102 -79.504940237095, 43.594289874029 -79.502923236165, 43.5951348819 -79.500648723831, 43.597531883013 -79.499597250262, 43.5979495106392 -79.4985994344106, 43.598631305676 -79.497751822264, 43.5996064174367 -79.4981756300662, 43.600923368051 -79.497269062197, 43.6018615226439 -79.4964415950768, 43.602007203105 -79.496043281399, 43.602300495353 -79.4947316940251, 43.602174248652 -79.49432132888, 43.602065449346 -79.492859514539, 43.607725133003 -79.487742427718, 43.610795465074 -79.486406438873, 43.613990057944 -79.485928653446, 43.617159041553 -79.485059920184, 43.6192717322 -79.481192278248, 43.620763010976 -79.482646073656, 43.622456208644 -79.481176038073, 43.622122293699 -79.479754349168, 43.622658221342 -79.478332631487, 43.623568809812 -79.477616572845, 43.623547414882 -79.476471392997, 43.626921815437 -79.475554156548, 43.629321513581 -79.473891156394, 43.629608871666 -79.472356840495, 43.630890238929 -79.47065080293, 43.6328859523111 -79.4736817180936, 43.632489924072 -79.474362989184, 43.63332338158 -79.475368178995, 43.63363818545 -79.475836592203, 43.63442919656 -79.476379127092, 43.635031593823 -79.476865217453, 43.6364691895129 -79.4778502543371, 43.6374564009051 -79.4792859023358, 43.6377059588191 -79.4787045291552, 43.6376596430447 -79.4779476422046, 43.6373493281345 -79.4776199086965, 43.6363479460928 -79.4771741579917, 43.6361345490783 -79.4770371133278, 43.636029859542 -79.4768356956475, 43.636868695362 -79.477097278588, 43.637583166923 -79.477528477468, 43.6379249292841 -79.4783888297903, 43.637770108711 -79.483160614751, 43.637940924756 -79.484094044941, 43.638235993408 -79.484984512858, 43.638466977341 -79.485178964745, 43.638822167712 -79.48537344153, 43.63932495221 -79.485439157092, 43.639641318774 -79.485676515096, 43.639920837121 -79.4870551726652, 43.641025309215 -79.4874628800733, 43.6414076973466 -79.4864329234496, 43.6415047523035 -79.4854458938079, 43.6418619552974 -79.486025218767, 43.641124316418 -79.4888469069, 43.640939910896 -79.489281406372, 43.6410583306496 -79.4897695779836, 43.6413572602374 -79.4900270605856, 43.642087069577 -79.4905527908105, 43.642793616877 -79.490799556916, 43.643562233702 -79.491078499799, 43.644695739264 -79.49187243763, 43.645549727521 -79.49230159689, 43.6464503366 -79.492451815777, 43.6484377538 -79.4922801544, 43.6484377708 -79.492151404367, 43.649431475563 -79.49144327778, 43.649881705151 -79.491067802061, 43.6504251294 -79.491121434121, 43.651201433846 -79.491550582367, 43.6519155961 -79.4922801204, 43.652059257969 -79.493009712341, 43.65210969734 -79.493782191054, 43.651931172331 -79.495370060798, 43.651775912076 -79.497741120775, 43.651853526556 -79.498459958, 43.652148493514 -79.501067011979, 43.652699689401 -79.502477867533, 43.653413840521 -79.503084074287, 43.654324912211 -79.503098871173, 43.65516616523 -79.502566504561, 43.656507096372 -79.501083255084, 43.657227032856 -79.499921831666, 43.658249661786 -79.499361247037, 43.659111291487 -79.499715200811, 43.659577017052 -79.50051446907, 43.660019468407 -79.501388820247, 43.660919812164 -79.502719181473, 43.661878369548 -79.504012016948, 43.663085277478 -79.506098903651, 43.662895120912 -79.507279062375, 43.662021949356 -79.509703770158, 43.661967618875 -79.51104486439, 43.66253422668 -79.512171402428, 43.663469428162 -79.512648837389, 43.664559848464 -79.512997515256, 43.666647632634 -79.513136985658, 43.667400420294 -79.51212847336, 43.667947569188 -79.511409650063, 43.671754092859 -79.512128495091, 43.673275045555 -79.512600564259, 43.673977353851 -79.512305539695, 43.674617552564 -79.511967581707, 43.675711674439 -79.509746671478, 43.676627351523 -79.508609435895, 43.679436167733 -79.507128826531, 43.680371149165 -79.505648270734, 43.68102683131 -79.505455177079, 43.6822411476 -79.505862852211, 43.682400187429 -79.506957180165, 43.682400217429 -79.50837337751, 43.682493308695 -79.508995682196, 43.682834695525 -79.509489163891, 43.6843243557368 -79.5104011575519, 43.686605241281 -79.51191381095, 43.687516844864 -79.511758219214, 43.68845945802 -79.512675557858, 43.690022715506 -79.512906248578, 43.692097997109 -79.513458842739, 43.693699902237 -79.51317458017, 43.695270723381 -79.512675696163, 43.696531282884 -79.511897821029, 43.697109206 -79.5121928361, 43.69720231307 -79.51386654256, 43.696954098432 -79.515583161364, 43.696814471049 -79.516763346782, 43.696892043448 -79.517836215905, 43.697248831275 -79.519252430253, 43.69800903083 -79.520175116142, 43.698629576113 -79.520754450412, 43.699281128325 -79.520904661979, 43.699839609278 -79.52150547379, 43.702631942276 -79.528779633661, 43.703469584266 -79.529230218972, 43.704059050675 -79.530088535644, 43.704617477711 -79.530871734906, 43.704927747941 -79.531783732726, 43.7050518352 -79.5334788449, 43.7045554348 -79.5348521699, 43.7045554558 -79.5362254659, 43.7080300621 -79.5362254689, 43.7095190905 -79.5389720109, 43.7124970905 -79.5382853734, 43.712497083963 -79.5382853994, 43.7144823132 -79.5382853814, 43.7169637699 -79.543091919, 43.7204376699 -79.5424052465, 43.7224226096 -79.540345319, 43.725896207 -79.5410319605, 43.7268885962 -79.5382854054, 43.7318504013 -79.5389720479, 43.7318503803 -79.5396586694, 43.7303618877 -79.5396586854, 43.7293695411 -79.541718599, 43.7303618837 -79.5437785645, 43.7323465536 -79.544465203, 43.7318503763 -79.5465251115, 43.732842671937 -79.549271710415, 43.7328426987 -79.5492716956, 43.7358194926 -79.5492717306, 43.73631565 -79.5506449976, 43.7378039976 -79.5492717376, 43.7392922802 -79.547211758, 43.7397884048 -79.5465251285, 43.7412766321 -79.5478984025, 43.7422688134 -79.5492716936, 43.7435089445935 -79.5516749788696, 43.7432609362 -79.5540782181, 43.7422688084 -79.556781900748, 43.7412766261 -79.5575114816, 43.7397883848 -79.5588847637, 43.7397883718 -79.5602580247, 43.7407805848 -79.5630046137, 43.7427648643 -79.5616313477, 43.7442530306 -79.5623180052, 43.7462372461 -79.5684978048, 43.746237234347 -79.568497886145, 43.7467332832 -79.5712443918, 43.7472293082 -79.5726176578, 43.7487174035 -79.5726176388, 43.7502054018 -79.5733043183, 43.7531814034 -79.5829173374, 43.755661224 -79.5842906515, 43.7571490927 -79.584977277, 43.7586369343 -79.5829173474, 43.7591328637 -79.5808574239, 43.760124738 -79.5801707844, 43.760620647 -79.5794841349, 43.7621083934 -79.5787974804, 43.7626043109 -79.5801707684, 43.757645049684 -79.602143416149, 43.7576450694 -79.6021434257, 43.749213427 -79.6385356546, 43.7442530476 -79.6344157355, 43.736315648 -79.629609261, 43.7025698822 -79.6103831617, 43.6688051037 -79.5911571145, 43.6688051007 -79.5911571095, 43.668805104037 -79.591157098734, 43.6643348391 -79.589097149, 43.6459534671 -79.6090098957, 43.6444628304 -79.6076365797, 43.6424753146 -79.5973369151, 43.6439659656 -79.5925303675, 43.6429721657 -79.5911570765, 43.641481465 -79.5884105215, 43.637506105274 -79.586350566, 43.637506092809 -79.586350566, 43.6375061014461 -79.5863505704755))'})

http://bl.ocks.org/d/9edfb43eda44d7e5d84e300e1385de7d

Same issue #85, I had to run ST_Simplify to make postgis adapter accept the polygon.

@slavajacobson Did you find a way to get this working from the Ruby side?

I'm currently having trouble doing a really basic INSERT:

wkt = "POLYGON ((-74.2503655987721 40.5091442241349, -74.2504120352793 40.5091183000754, -74.2503322759711 40.5090405104492))"

Geometry.new.tap do |g|
  g.shape = wkt
  g.save!
end

# ActiveRecord::StatementInvalid:
# PG::InvalidTextRepresentation: ERROR:  invalid input syntax for type polygon: "POLYGON ((-74.2503655987721 40.5091442241349, -74.2504120352793 40.5091183000754, -74.2503322759711 40.5090405104492))"
#       : INSERT INTO "geometries" ("shape") VALUES ($1) RETURNING "id"

On the SQL side, I can add ST_GeomFromText to make it work:

INSERT INTO "geometries" ("shape") VALUES (ST_GeomFromText('POLYGON((-74.2503655987721 40.5091442241349, -74.2504120352793 40.5091183000754, -74.2503322759711 40.5090405104492))', 4326)::polygon);

# INSERT 0 1

@slavajacobson @delner It would be helpful if could please provide an update on this. My workaround now is to use ST_Simplify.

Depending on the factory being used, there may be floating point issues, specifically the RGeo::Geographic.spherical_factory (rgeo/rgeo#212).

To parse invalid polygons, use a factory that has uses_lenient_assertions set to true when reading data from the database via the SpatialFactoryStore.

@keithdoggett is it possible to enable uses_lenient_assertions for specific models/queries?

@andrerigon no, not directly. You have to use the SpatialFactoryStore and register factories based on the properties of your models.

As of version 3, uses_lenient_assertions has been deprecated.

I'd like to know if there's a different method to bypass RGeo thinking the polygon is incorrect besides ST_Simplifying until it stops complaining? Haven't been able to find anything yet.

@sebastialonso can you open another issue with some more details? In version 3 we allow you to create invalid polygons without raising an error, but trying to call certain methods on them will raise an error unless unsafe_* methods are used.