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

Getting error while merging two polygons, core.js:1448 ERROR TypeError: Ht.toLineString is not a function at Wi.getErrorMessage (jsts.min.js:18) #337

Closed
TarunNarula opened this issue May 21, 2018 · 10 comments

Comments

@TarunNarula
Copy link

core.js:1448 ERROR TypeError: Ht.toLineString is not a function
at Wi.getErrorMessage (jsts.min.js:18)
at Wi.checkValid (jsts.min.js:18)
at ji.checkValid (jsts.min.js:18)
at Function.ji.checkValid (jsts.min.js:18)
at Ji.computeOverlay (jsts.min.js:18)
at Ji.getResultGeometry (jsts.min.js:18)
at Function.Ji.overlayOp (jsts.min.js:18)
at Sr.getResultGeometry (jsts.min.js:19)
at Function.Sr.overlayOp (jsts.min.js:19)
at bt.union (jsts.min.js:9)

@bjornharrtell
Copy link
Owner

Can you provide the input polygons? Also, is this the latest released JSTS?

@TarunNarula
Copy link
Author

First One is this

[[73.87258529663086,18.571897391345317],[73.87498855590823,18.570514248174],[73.87498855590819,18.570026077317547],[73.87546062469484,18.570026077317536],[73.87799263000488,18.56884632531228],[73.87919425964354,18.56904973141263],[73.87863636016846,18.571734669201557],[73.87820720672607,18.572649979240506],[73.87870073318481,18.5726916887679],[73.88065338134766,18.572955081495028],[73.8813408229665,18.57305490624326],[73.8824987411499,18.57315848269475],[73.88402685350808,18.573346602686104],[73.8848794052287,18.574659380022307],[73.88473033905031,18.575721317022108],[73.8846581069021,18.576464330911588],[73.88513803482056,18.57728747459083],[73.88515949249266,18.57791800149772],[73.88601779937743,18.57799935963841],[73.88747692108154,18.578894296623254],[73.88783379059926,18.579590099501704],[73.888463973999,18.57950447823721],[73.89078140258789,18.580643478072304],[73.8914680480957,18.580643478072304],[73.8916826248169,18.58080619171312],[73.89290571212769,18.580887548475292],[73.89346361160278,18.581416366482724],[73.89402151107788,18.58153840117451],[73.89494419097902,18.5823519635533],[73.89494419097898,18.582758743286334],[73.89545917510988,18.583165522048397],[73.89637055741167,18.583125922433695],[73.89623956221445,18.581029922715615],[73.89616816116684,18.580002343726182],[73.89586687088013,18.57596539447271],[73.89580249786377,18.575517918879676],[73.89569520950317,18.57476534364279],[73.89926736903604,18.575406613469156],[73.89983654022221,18.573382223734214],[73.8998896415275,18.57270345175373],[73.89859427029204,18.570942523900623],[73.89805555343627,18.56988369388786],[73.89724016189575,18.56843951238381],[73.89685392379761,18.567910654126216],[73.89526605606079,18.565978273474297],[73.89434337615967,18.565164632966653],[73.8943862915039,18.56496122223341],[73.89698266983032,18.563232221208416],[73.89857053756714,18.562154129347366],[73.8974118232727,18.55985553338994],[73.89726161956787,18.557841693786546],[73.89475107192993,18.55806545491602],[73.89142513275146,18.559204597935615],[73.88957977294922,18.552674764294725],[73.8850736618042,18.553264697224463],[73.88354644384579,18.55341243747033],[73.87919425964351,18.552756134475185],[73.87867927551274,18.553915655332748],[73.87861490249638,18.554322502889875],[73.8811378593717,18.55520687831383],[73.88103961944579,18.55552269753379],[73.87906551361083,18.55590919909729],[73.87781626319298,18.556202616258435],[73.87526750564575,18.557007672446662],[73.87537479400635,18.557556906470193],[73.87475252151489,18.558106138726224],[73.87387275695801,18.55832989950898],[73.87249946594237,18.55861468553544],[73.87204885482788,18.56258129863545],[73.87189865112305,18.564188259235063],[73.87136220932007,18.56577486371121],[73.87136220932007,18.56634441043665],[73.87159824371338,18.567463157396705],[73.87198448181152,18.568744622171124],[73.87222051620483,18.569334499545594],[73.87243509292603,18.57012777969454],[73.8727355003357,18.571083779073724],[73.87258529663086,18.571897391345317]]

Second one is this:

[[73.8895797729492,18.55267476429471],[73.89142513275146,18.559204597935615],[73.89475107192993,18.55806545491602],[73.89726161956791,18.557841693786543],[73.8974118232727,18.55985553338995],[73.89857053756714,18.562154129347366],[73.89438629150395,18.56496122223341],[73.89434337615967,18.565164632966656],[73.89526605606079,18.565978273474297],[73.89685392379761,18.567910654126205],[73.89724016189577,18.568439512383797],[73.89805555343628,18.56988369388786],[73.89859427029205,18.570942523900626],[73.89988964152748,18.572703451753714],[73.89983654022217,18.573382223734214],[73.89926736903605,18.575406613469173],[73.8956952095032,18.57476534364279],[73.89580249786377,18.57551791887966],[73.8958668708801,18.57596539447271],[73.89616816116684,18.58000234372618],[73.89637055741169,18.583125922433712],[73.89696121215819,18.582962132788726],[73.8975620269775,18.583124844215888],[73.8982057571411,18.583694332987502],[73.89848470687866,18.58511804659019],[73.8988494873047,18.585809560333757],[73.90026569366455,18.58768070109809],[73.90026569366455,18.588778969802078],[73.90172481536865,18.58865694029573],[73.90232563018796,18.58947046868708],[73.90277624130249,18.58950251954725],[73.9029049873352,18.590019598155024],[73.90412807464601,18.590039936249468],[73.90571594238281,18.590243317060406],[73.90743255615234,18.590772106032418],[73.90932083129881,18.591585624322512],[73.90949249267578,18.590609401908164],[73.91168117523188,18.59060940190818],[73.9114236831665,18.587395963611716],[73.91258239746094,18.5871519025304],[73.91408443450925,18.58947046868708],[73.91623020172122,18.591138189743788],[73.91841888427734,18.592521165552828],[73.9207768496047,18.59302632616458],[73.92122983932495,18.592968596498675],[73.92131567001343,18.592724543401186],[73.9218091964722,18.59311096074605],[73.92238519281665,18.593472726721874],[73.92309221024666,18.593758581272844],[73.92459869384766,18.595775181983655],[73.92502784729004,18.596120917575437],[73.92595052719116,18.5951650586388],[73.92713069915771,18.594310882283725],[73.92781734466553,18.59441257016971],[73.92874002456665,18.594737970996796],[73.92968416213989,18.595470120584473],[73.93045663833618,18.595815856795596],[73.93152952194214,18.59593788117311],[73.93320322036743,18.595470120584473],[73.93629312515257,18.594697295927407],[73.93983364105225,18.593700753692875],[73.94365310668945,18.592724543401186],[73.9458417892456,18.59215508481379],[73.94575595855713,18.59138224511424],[73.94479036331177,18.591727989623813],[73.9445114135742,18.589307763319596],[73.94354581832886,18.589307763319596],[73.94365310668945,18.588616263774174],[73.94341707229614,18.58796543810859],[73.94363164901733,18.584751949942728],[73.94386768341064,18.58391806019851],[73.94399642944336,18.581701113960964],[73.94380331039429,18.580175675489684],[73.9433741569519,18.579687532295456],[73.94294500350952,18.579321423982368],[73.94161462783813,18.579341763353725],[73.94150733947754,18.577918001497725],[73.94142150878906,18.576412868891282],[73.9435029029846,18.57588403536134],[73.94343852996826,18.57431786490014],[73.9378809928894,18.573666984632577],[73.93745183944702,18.575761996621463],[73.93461942672728,18.575802676211122],[73.9347696304321,18.575395879877757],[73.93616437911987,18.573361883651852],[73.93500566482541,18.57289406108779],[73.93421173095702,18.572283855814465],[73.93380403518675,18.57258895872411],[73.93350362777709,18.573321203479843],[73.9323878288269,18.574724663805608],[73.93150806426998,18.574745003725432],[73.93107891082762,18.57415514506616],[73.93099308013916,18.573178822801378],[73.93060684204104,18.57283304065872],[73.93155097961426,18.571978752358987],[73.93116474151608,18.571510926000332],[73.93019914627077,18.572446577434185],[73.92876148223874,18.571165140475575],[73.92822504043579,18.571409224448182],[73.92740964889525,18.56984301288611],[73.92743110656738,18.569395521226504],[73.92747402191162,18.568358149681686],[73.93026351928711,18.568256446249443],[73.93041372299194,18.568012357764648],[73.93079996109009,18.568032698485055],[73.93097162246704,18.568256446249443],[73.9313793182373,18.568236105555727],[73.93161535263062,18.568053039203036],[73.93285989761353,18.568236105555727],[73.93427610397339,18.568622578321694],[73.93438339233398,18.568358149681686],[73.93459796905516,18.56339495146362],[73.93230199813839,18.563232221208416],[73.93144369125368,18.563049149485764],[73.9279246330261,18.56278471220626],[73.92818548589426,18.55738990620533],[73.92718582196245,18.557328234163258],[73.92698049545288,18.557536564500843],[73.92630656252796,18.55765461636562],[73.92555255519872,18.55768325238508],[73.92540892821923,18.557863474631908],[73.92448678880632,18.5578885356325],[73.92445531884314,18.557668708402076],[73.92354555938617,18.557959398782035],[73.92265556838491,18.558351594697754],[73.9220469440038,18.557792645090863],[73.9213613620273,18.557763083999685],[73.92120838165283,18.556499120848954],[73.9208436012268,18.55548201310778],[73.92080068588255,18.554932772407458],[73.92069339752194,18.55472934947734],[73.9193630218506,18.554770034082768],[73.91833305358885,18.555217564102307],[73.91852617263793,18.556722883738622],[73.91891241073608,18.55826887387004],[73.91882658004761,18.559875875082895],[73.91856908798218,18.561015006017442],[73.91408443450926,18.559469040763407],[73.91133785247797,18.558533318147784],[73.91047954559326,18.558187506317534],[73.90872001647949,18.557211092661458],[73.90745401382446,18.556316041902846],[73.90663862228394,18.555543039743167],[73.9051151275635,18.554790376381828],[73.90420935522889,18.55453876892446],[73.90086650848386,18.553610519028553],[73.89646768569949,18.552267912810592],[73.89475107192992,18.551149066229875],[73.89354489218572,18.549925311749753],[73.89254093170166,18.54870792096767],[73.89082431793214,18.547019441743775],[73.88957977294919,18.545981934180883],[73.88875419544755,18.54583840314899],[73.8895797729492,18.55267476429471]]

@TarunNarula
Copy link
Author

I am using this link to include library:
https://cdn.rawgit.com/bjornharrtell/jsts/gh-pages/1.0.2/jsts.min.js

@bjornharrtell
Copy link
Owner

That's quite old - can you try https://cdn.rawgit.com/bjornharrtell/jsts/gh-pages/1.6.0/jsts.min.js instead?

@TarunNarula
Copy link
Author

After updating the version, I got this error:

core.js:1448 ERROR Jn {pt: E, name: "TopologyException", message: "found non-noded intersection between LINESTRING ( …8.51064188615364, 73.86835813522339, undefined) ]", stack: "Error↵ at Jn.m (https://cdn.rawgit.com/bjornhar…arrtell/jsts/gh-pages/1.6.0/jsts.min.js:8:359668)"}

@bjornharrtell
Copy link
Owner

Ok that means your polygons have some very close vertices and/or edges creating numerical robustness issues at the reported location and will have to be preprocessed to be able to union. From the FAQ:

In some cases you might get a TopologyException thrown as an Error. This is expected if a calculation fails due to precision issues. To resolve this issue try reducing precision in the input and at the same time make sure the input is valid as defined by the OGC Simple Features specification. To reduce precision GeometryPrecisionReducer can be used.

@TarunNarula
Copy link
Author

TarunNarula commented May 21, 2018

I am using this in Angular 5 project, How can i use GeometryPrecisionReducer in it ???

@TarunNarula
Copy link
Author

?

@bjornharrtell
Copy link
Owner

I don't know, I have never used Angular 5.

@TarunNarula
Copy link
Author

Thanks a lot, I resolved the issue by removing the coordinates that were coming in the error.

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

No branches or pull requests

2 participants