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

Problems with fromObject() method #45

Closed
maciekfreak opened this issue Apr 28, 2014 · 4 comments
Closed

Problems with fromObject() method #45

maciekfreak opened this issue Apr 28, 2014 · 4 comments

Comments

@maciekfreak
Copy link

Hi,

I have a problem with fromObject method.

My WKT:

POLYGON((15.5848687374 53.1204806794,15.5849691018 53.1205107954,15.5852754108 53.1206446442,15.5853709188 53.1206961327,15.5857148196 53.120816812,15.5858446817 53.1208672209,15.5859952282 53.1209139596,15.5864089163 53.1210141294,15.5865033451 53.121048023,15.5865760104 53.1210888249,15.5868271011 53.1213199265,15.587030168 53.1214767641,15.587152116 53.1215335406,15.5872710064 53.1215681894,15.5874675982 53.1216058605,15.5876965656 53.1216394298,15.5878874017 53.1216845487,15.5879645636 53.1216952347,15.5881557594 53.1217085113,15.5885541591 53.1217152035,15.5888944625 53.1216709482,15.5889320542 53.1216728912,15.5890957308 53.1217136924,15.5892757751 53.1217855802,15.5894425094 53.1218401975,15.5896477347 53.1218794875,15.5898700471 53.1218955704,15.5900975756 53.1218991324,15.5903472274 53.1218842368,15.5904680962 53.1218612457,15.5906868114 53.1218283242,15.5911645312 53.1217688495,15.591390261 53.1217454267,15.5916319988 53.1217317183,15.5920579177 53.1216966379,15.5922464156 53.1216859519,15.5923845515 53.1216656592,15.5933023995 53.1215746658,15.5934851418 53.1215471411,15.593613565 53.1215178893,15.5936817336 53.121491444,15.5938342586 53.1213999105,15.5939499114 53.1213249997,15.5941923686 53.1211498116,15.5944215159 53.1209627493,15.5946213452 53.1207710446,15.5946486846 53.1207143749,15.5946522819 53.1206836114,15.5946495839 53.1206602959,15.5946053373 53.120598121,15.5945540759 53.1205588299,15.5944936415 53.1205245042,15.5943252884 53.1204498078,15.5942171899 53.1204079259,15.5939759917 53.1203288036,15.5936632075 53.1202378074,15.5930243292 53.1200887373,15.5929975294 53.1200790223,15.5929723484 53.120062399,15.5929036402 53.1199789583,15.5928543573 53.1198915235,15.5928253991 53.1197943736,15.5927701808 53.1196894514,15.5927527339 53.119621662,15.5927235959 53.119548907,15.5927068685 53.1195179267,15.5926708956 53.1194751804,15.5926261094 53.1193940054,15.5924834769 53.119097586,15.5924586556 53.1190323864,15.5923314915 53.1187991135,15.5921895785 53.1185576353,15.5920386722 53.118376175,15.5919595319 53.1182482563,15.5917920781 53.1179104844,15.591743155 53.117826068,15.591732543 53.1178236931,15.5917185136 53.1178021032,15.5915062736 53.1173470935,15.5914631061 53.1172729313,15.5914077079 53.1171522421,15.5913758719 53.1171024766,15.5913255099 53.1170441828,15.5911109316 53.1166986289,15.5910377268 53.1165325979,15.5908632583 53.1162115454,15.5907188272 53.1159719958,15.5906409459 53.11579657,15.5906139663 53.1157645075,15.5905893248 53.1157086949,15.5905720579 53.1156947687,15.5905524526 53.1156888312,15.5904607218 53.1156837573,15.5904224107 53.115686888,15.5894662515 53.1158429904,15.5888831311 53.1159270869,15.5885376116 53.1159812799,15.5885307767 53.1159853821,15.5876145474 53.1161095292,15.5868893341 53.1162305452,15.5866112638 53.1162708118,15.5860344386 53.1163370951,15.5851725284 53.1164797011,15.5842183477 53.1166010399,15.5839917186 53.1166338575,15.5833211841 53.1167397587,15.5826616213 53.1168290351,15.5823882274 53.1168705966,15.581255981 53.1170557336,15.5807859953 53.1171212601,15.5804185323 53.117179014,15.579622992 53.1172881524,15.5790422098 53.1173796946,15.5776921476 53.1175620227,15.577531169 53.1175775676,15.5771917648 53.1176295995,15.5769404943 53.1176787167,15.576841389 53.1177071075,15.5768171073 53.1177441342,15.5768367125 53.1177676673,15.5768577566 53.1177817007,15.5772689267 53.1179589536,15.5776964644 53.1181137523,15.578008709 53.1182188943,15.578231561 53.1182811805,15.5786107151 53.1184022984,15.5786889562 53.1184234562,15.5788979586 53.1184936223,15.5789882505 53.1185300007,15.5793873696 53.1186641795,15.579409493 53.1186675259,15.580054127 53.1188822326,15.5807696276 53.1191419519,15.5809253902 53.119191823,15.5812646144 53.1193153131,15.5824074729 53.1196883719,15.5829116328 53.1198591402,15.5834318007 53.1200638023,15.5837559163 53.1201823245,15.5838417117 53.1202206444,15.5841656475 53.1203361437,15.584362599 53.1203898994,15.5844883242 53.1204181805,15.5848687374 53.1204806794),(15.5852495104 53.1187050915,15.585126663 53.1187559347,15.585081517 53.1187638148,15.58506425 53.1187630592,15.585048422 53.1187536678,15.5850316946 53.1187180452,15.5850322342 53.1187059551,15.5850581346 53.1186453966,15.585100043 53.1185982236,15.5851620963 53.118549971,15.5853376439 53.1184377053,15.5853736168 53.1184372735,15.5854480807 53.118463289,15.5854621101 53.1184856342,15.5854567142 53.1185246033,15.5853889053 53.1186112852,15.5852495104 53.1187050915),(15.5902364309 53.1184313364,15.5901310303 53.1184156839,15.5900812079 53.1183974407,15.5900196943 53.1183618179,15.5899110562 53.1182680108,15.5898786806 53.1182142525,15.589862133 53.1181726923,15.5898686082 53.1181489436,15.589882098 53.1181326434,15.5899743684 53.1180805041,15.5900678979 53.1180360292,15.5901810326 53.1180048319,15.590254777 53.1180000822,15.5903011821 53.1180062353,15.5903508246 53.1180222117,15.5903939921 53.1180442333,15.5905713384 53.1182197579,15.5906123475 53.1182889528,15.5906062321 53.118324036,15.5905256528 53.118357392,15.5904278066 53.1184058607,15.5903421911 53.1184272344,15.5902839151 53.1184326318,15.5902364309 53.1184313364),(15.590562525 53.1206705504,15.5906742208 53.1205506263,15.5912138141 53.1202400742,15.5912720901 53.1202305752,15.5912889974 53.1202381312,15.591318675 53.1202669521,15.5913587848 53.120347046,15.5913640008 53.1204216346,15.5913553673 53.1204733393,15.5913632814 53.1205432862,15.5913911604 53.1206001719,15.5914357667 53.120645076,15.5916775045 53.1207693175,15.5917320034 53.1208061257,15.5918077263 53.1208457404,15.5920726666 53.1210019321,15.5921480298 53.1210399274,15.5923131453 53.1211086861,15.5923993004 53.1211181849,15.5924563174 53.1211159181,15.5925712507 53.1211002666,15.5926023673 53.1210902281,15.5927081275 53.1210454325,15.592760648 53.1210165042,15.5930326029 53.1209120167,15.5930683959 53.1209088864,15.5931178587 53.120911477,15.5931495148 53.1209187091,15.5932047332 53.1209664193,15.5931982581 53.1210314001,15.5932068915 53.1210927108,15.5931968191 53.1211219628,15.5931759549 53.1211567199,15.5931495148 53.1211832734,15.5931124627 53.1212112301,15.593052388 53.1212329262,15.5929842194 53.1212415615,15.5929191085 53.121240698,15.5928232408 53.1212300118,15.5927005732 53.121224183,15.5924850957 53.1212358406,15.5923885085 53.121246095,15.5923419236 53.121266172,15.5922778919 53.1213077292,15.5921793262 53.121418908,15.5920983872 53.1214661859,15.5920577379 53.1214766561,15.5919372287 53.1214942504,15.5916393732 53.1215504872,15.5914791141 53.1215962538,15.5912506863 53.1216421283,15.5911783808 53.1216482809,15.5910855707 53.1216453665,15.5909810695 53.1216351122,15.5906098294 53.1215843804,15.5905375239 53.121559878,15.590419353 53.1214806499,15.5903855385 53.1214478361,15.5903508246 53.1213759477,15.5904011867 53.1209871441,15.5904231301 53.1209273444,15.5904731324 53.1208327874,15.590561266 53.1206920309,15.590562525 53.1206705504),(15.589504023 53.1183745557,15.5893106688 53.1184020825,15.5890453688 53.1184098547,15.5889924886 53.1184067243,15.5888550722 53.1183858903,15.5888356469 53.1183619258,15.5888480575 53.1183413077,15.5888637057 53.118330189,15.5889583144 53.1182879813,15.589039793 53.1182590511,15.5891237897 53.1182465291,15.5891971743 53.1182484722,15.5893203815 53.1182832315,15.589504023 53.1183745557))

I'm calling fromObject method:

var wkt = new Wkt.Wkt();
    wkt.fromObject(nowEditingShape);
    console.log(wkt.components);
    wktdata = wkt.write();
    console.log(wktdata);

wkddata returns on my object Polygon but with undefined on the end:

POLYGON((15.58486873740003 53.1204806794,15.58496910179997 53.1205107954,15.585275410800023 53.1206446442,15.585370918799981 53.1206961327,15.58571481960007 53.120816812,15.585844681699996 53.1208672209,15.585995228199977 53.1209139596,15.586408916300002 53.1210141294,15.586503345100027 53.121048023,15.586576010399995 53.1210888249,15.58682710109997 53.1213199265,15.587030167999956 53.1214767641,15.58715211599997 53.1215335406,15.587271006399988 53.1215681894,15.587467598199964 53.1216058605,15.587696565600027 53.1216394298,15.587887401699959 53.1216845487,15.587964563600053 53.1216952347,15.588155759400024 53.1217085113,15.5885541591 53.1217152035,15.58889446249998 53.1216709482,15.588932054199972 53.1216728912,15.589095730799954 53.1217136924,15.589275775099964 53.1217855802,15.589442509399987 53.1218401975,15.589647734700065 53.1218794875,15.589870047100021 53.1218955704,15.590097575599998 53.1218991324,15.590347227400002 53.1218842368,15.59046809619997 53.1218612457,15.590686811400019 53.1218283242,15.59116453119998 53.1217688495,15.591390261000015 53.1217454267,15.59163199880004 53.1217317183,15.592057917700004 53.1216966379,15.592246415600016 53.1216859519,15.592384551500004 53.1216656592,15.593302399499976 53.1215746658,15.593485141799988 53.1215471411,15.593613564999941 53.1215178893,15.593681733599965 53.121491444,15.593834258600054 53.1213999105,15.593949911399932 53.1213249997,15.594192368600034 53.1211498116,15.594421515899967 53.1209627493,15.59462134520004 53.1207710446,15.594648684599974 53.1207143749,15.59465228190004 53.1206836114,15.594649583900036 53.1206602959,15.594605337299981 53.120598121,15.594554075899964 53.1205588299,15.59449364149998 53.1205245042,15.5943252884 53.1204498078,15.594217189900064 53.1204079259,15.593975991700063 53.1203288036,15.593663207499958 53.1202378074,15.593024329200034 53.1200887373,15.592997529400009 53.1200790223,15.592972348400053 53.120062399,15.592903640200007 53.1199789583,15.592854357299984 53.1198915235,15.59282539909998 53.1197943736,15.592770180800017 53.1196894514,15.592752733899943 53.119621662,15.592723595899997 53.119548907,15.592706868500045 53.1195179267,15.592670895600008 53.1194751804,15.592626109400044 53.1193940054,15.592483476900043 53.119097586,15.592458655600012 53.1190323864,15.592331491499976 53.1187991135,15.592189578499983 53.1185576353,15.592038672200033 53.118376175,15.591959531899988 53.1182482563,15.59179207810007 53.1179104844,15.591743155000017 53.117826068,15.591732543000035 53.1178236931,15.591718513599972 53.1178021032,15.591506273599975 53.1173470935,15.591463106100036 53.1172729313,15.591407707899975 53.1171522421,15.591375871900027 53.1171024766,15.591325509900003 53.1170441828,15.591110931600042 53.1166986289,15.591037726799982 53.1165325979,15.590863258300033 53.1162115454,15.590718827200021 53.1159719958,15.590640945899963 53.11579657,15.590613966299998 53.1157645075,15.590589324800021 53.1157086949,15.590572057899976 53.1156947687,15.590552452600036 53.1156888312,15.590460721800014 53.1156837573,15.590422410700057 53.115686888,15.589466251499971 53.1158429904,15.588883131100033 53.1159270869,15.588537611600032 53.1159812799,15.588530776700054 53.1159853821,15.587614547399994 53.1161095292,15.586889334099965 53.1162305452,15.586611263800023 53.1162708118,15.586034438599995 53.1163370951,15.585172528399994 53.1164797011,15.584218347700016 53.1166010399,15.583991718600032 53.1166338575,15.583321184099987 53.1167397587,15.582661621299962 53.1168290351,15.582388227399974 53.1168705966,15.581255981000027 53.1170557336,15.580785995299948 53.1171212601,15.580418532299973 53.117179014,15.57962299199994 53.1172881524,15.579042209800036 53.1173796946,15.577692147600033 53.1175620227,15.57753116899994 53.1175775676,15.577191764799977 53.1176295995,15.576940494300061 53.1176787167,15.576841389000037 53.1177071075,15.57681710730003 53.1177441342,15.57683671250004 53.1177676673,15.57685775660002 53.1177817007,15.577268926700071 53.1179589536,15.577696464399992 53.1181137523,15.57800870899996 53.1182188943,15.578231560999939 53.1182811805,15.578610715100012 53.1184022984,15.57868895620004 53.1184234562,15.57889795860001 53.1184936223,15.57898825050006 53.1185300007,15.5793873696 53.1186641795,15.579409492999957 53.1186675259,15.58005412700004 53.1188822326,15.580769627600034 53.1191419519,15.580925390200036 53.119191823,15.58126461439997 53.1193153131,15.582407472900059 53.1196883719,15.582911632800005 53.1198591402,15.583431800700055 53.1200638023,15.583755916299992 53.1201823245,15.58384171169996 53.1202206444,15.584165647499958 53.1203361437,15.584362598999974 53.1203898994,15.584488324200038 53.1204181805,15.58486873740003 53.1204806794),(15.585388905299965 53.1186112852,15.585456714200063 53.1185246033,15.585462110100025 53.1184856342,15.585448080699962 53.118463289,15.585373616799984 53.1184372735,15.585337643899948 53.1184377053,15.585162096299996 53.118549971,15.585100043000011 53.1185982236,15.58505813459999 53.1186453966,15.585032234200071 53.1187059551,15.585031694600048 53.1187180452,15.585048422 53.1187536678,15.58506424999996 53.1187630592,15.585081516999935 53.1187638148,15.585126662999983 53.1187559347,15.58524951039999 53.1187050915,15.585388905299965 53.1186112852),(undefined undefined),(undefined undefined),(undefined undefined)) 

I'm stuck on this, any help will be appreciated!

@arthur-e
Copy link
Owner

Thanks for the report. fromObject() depends a great deal on which mapping library you're using. Are you using ESRI, Leaflet, or the Google Maps API?

@maciekfreak
Copy link
Author

Google Maps API

@maciekfreak
Copy link
Author

Similar problem with fromObject I have with another google maps API object:

WKT:

POLYGON((17.0675611822 52.1830252232,17.0675611822 52.1830201502,17.0675397783 52.1830201502,17.0675611822 52.1830252232,17.0675611822 52.1830415449,17.0675779096 52.183029083,17.0675611822 52.1830252232),(17.0758867458 52.1766257447,17.0758009505 52.1765399327,17.075736559 52.1765613305,17.075371794 52.176840274,17.0752430111 52.1769691014,17.0747998252 52.1773014259,17.0745562888 52.1774840765,17.0729992026 52.1787212496,17.0729900296 52.1787285289,17.072453494 52.1791577869,17.0723247111 52.1792649904,17.0722819034 52.1793078938,17.0712439059 52.1801626446,17.0711874285 52.1802091867,17.0709084588 52.180445205,17.0708442472 52.1805525158,17.0706080852 52.180659716,17.0702005125 52.1809601398,17.0697283684 52.1813463646,17.0694350096 52.1815786272,17.0692134166 52.1817540916,17.0690202423 52.181947201,17.0687628563 52.1821189143,17.0681191216 52.1826338297,17.0680547301 52.1826768401,17.0676252139 52.1829942338,17.0675779096 52.183029083,17.0678201869 52.1830860989,17.0679045433 52.1831059497,17.0680117425 52.1831488494,17.0682693084 52.1832346487,17.0683551037 52.1832776585,17.0685052905 52.1833205581,17.0685266943 52.1833205581,17.0690117886 52.1835042867,17.0699429467 52.1838569642,17.0702219163 52.1839427621,17.0703291155 52.1838354596,17.0710372417 52.1832990532,17.0713162114 52.18306305,17.0716595725 52.1828270455,17.0716809764 52.1828055403,17.071723964 52.1827626403,17.0717667717 52.1827411351,17.0717883555 52.1827197402,17.0718126372 52.1826994482,17.0719171384 52.1826124347,17.0725822769 52.1820974088,17.072818259 52.1819043001,17.0731186326 52.1816682895,17.0731402163 52.1816682895,17.0732044279 52.1816038826,17.0736184758 52.181281847,17.0739769456 52.1810030416,17.0748782461 52.1802734853,17.0751786196 52.1800803686,17.0754396029 52.17987159,17.0757149753 52.1796512299,17.0758009505 52.1795869304,17.076101324 52.179372304,17.076594872 52.1789646654,17.0769382331 52.1787071321,17.0772431033 52.1784531266,17.077324402 52.178385296,17.0775603841 52.1782135683,17.0777321546 52.1780633473,17.078053932 52.1777844115,17.078182715 52.1776986017,17.078182715 52.1776772044,17.0782041188 52.1776556967,17.0782685103 52.1776127917,17.0782685103 52.1775912841,17.0782899141 52.1775912841,17.0782471064 52.1775698867,17.078053932 52.1774840765,17.0776461794 52.1773338531,17.0775819678 52.1773123453,17.0774959927 52.1772694399,17.0769957897 52.1771394001,17.0764231015 52.1769904991,17.0761441318 52.1768188763,17.076101324 52.1767759705,17.0759081497 52.1766471425,17.0758867458 52.1766257447))

fromObject:

MULTIPOLYGON(((),(),(),(),(),(),()),((),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),())) 

@arthur-e
Copy link
Owner

Yes, the Google Maps API makes it very difficult to distinguish polygons in a collection (MULTIPOLYGON) from inner rings that are holes (POLYGON or MULTIPOLYGON with holes). See Issue #33. The Leaflet and ESRI ArcGIS extensions do not have this problem. There is no known solution at this time.

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

No branches or pull requests

2 participants