This works fine for the most part, but I have found that with the following data it gives an unexpected result.
Repro data here as WKT. For repro these would need to be converted into Geometry objects
startPoint = POINT (-2.712395 52.984574)
endPoint = POINT (-2.70684 52.968237)
lineString = MULTILINESTRING ((-2.7101237699999388 52.98707844100005, -2.710402958999964 52.98692973500005, -2.7106821479999326 52.986781026000074, -2.710912693999944 52.98665822700008, -2.7109616239999355 52.98663251700003, -2.711242469999945 52.98648495200007, -2.711523313999976 52.98633738600006, -2.7115623139999343 52.98631689300004, -2.711807207999925 52.98618681600004, -2.711991945999955 52.98607945500004, -2.712064664999957 52.98601617400004, -2.7121977409999545 52.98580604300008, -2.7122973929999716 52.98560095300007, -2.7123326469999256 52.98552739400003, -2.7123847929999556 52.98538655300007, -2.712396078999973 52.985191056000076, -2.7123918649999723 52.985158271000046, -2.7123678229999655 52.98497120900004, -2.7123672129999363 52.98493410400005, -2.712366061999944 52.98486418600004, -2.7123695699999644 52.984777947000055, -2.712383562999946 52.98472071700007, -2.712382110999954 52.984674417000065, -2.7123790849999523 52.98457785200003, -2.7123761899999295 52.98448548500005, -2.712375139999949 52.984452015000045, -2.712375050999981 52.98441734000005, -2.712374873999977 52.98435167300005, -2.7123499759999277 52.984262012000045, -2.712335611999947 52.98421028100006, -2.7122960379999768 52.98404355100007, -2.7122177149999516 52.983931505000044, -2.71213851899995 52.98383595000007, -2.712117189999958 52.98381021500006, -2.712037564999946 52.98373772700006, -2.7119864009999333 52.98369885100004, -2.711925239999971 52.98365238900004, -2.711890862999951 52.98362627400007, -2.7117800889999444 52.98354212300006, -2.7117217719999758 52.983497818000046, -2.7116817479999327 52.98346742100006, -2.7114611509999804 52.98330087200003, -2.711373728999945 52.98323489100005, -2.7112355759999787 52.983122120000075, -2.7110142049999695 52.98294141700006, -2.7107928349999497 52.98276071300006, -2.710755922999965 52.982730581000055, -2.710562419999974 52.98258421500003, -2.71053324199994 52.98256225200004, -2.7104786749999334 52.98252117700008, -2.710340773999974 52.98240376800004, -2.7103153709999788 52.98238197500007, -2.7102245129999574 52.98224873100003, -2.710213759999931 52.98219512600008, -2.7102030679999416 52.98214182600003, -2.710240608999925 52.98202862100004, -2.710269933999939 52.981975927000065, -2.710321952999948 52.98188245500006, -2.7103808269999377 52.981814358000065, -2.710414913999955 52.981769565000036, -2.710516211999959 52.98163644700003, -2.7105745409999713 52.98155394300005, -2.7106516249999686 52.98144491000005, -2.7107172199999354 52.98135016900005, -2.7108013279999454 52.98122839500007, -2.710855548999973 52.98114510000005, -2.7109293769999567 52.98103168600005, -2.7109524479999436 52.980996524000034, -2.7109896849999586 52.980940470000064, -2.7110173429999804 52.98089879200006, -2.711119139999937 52.98072978600004, -2.7112395049999805 52.980529818000036, -2.711372153999946 52.98030707500004, -2.711438912999938 52.98019497200005, -2.711508561999949 52.98009809900003, -2.7116170969999303 52.97994714100008, -2.711639396999942 52.97988850100006, -2.7117020879999245 52.979723645000036, -2.711720889999981 52.97966923200005, -2.7117969069999504 52.97944923800003, -2.7118460239999536 52.979307092000056), (-2.7118460239999536 52.979307092000056, -2.7118760659999452 52.97922015000006, -2.7119206319999307 52.97908692500005, -2.7119943169999488 52.97886664400005, -2.712068001999967 52.97864636200006, -2.71208732599996 52.97858859400003, -2.71213967999995 52.978425841000046, -2.712210640999956 52.97820523300004, -2.7122816029999512 52.97798462600008, -2.7123525629999676 52.97776401900006, -2.7123872399999414 52.977656212000056, -2.7124237719999655 52.97754344200007, -2.7124952189999476 52.97732289100003, -2.7125666649999403 52.97710234200008, -2.712638110999933 52.97688179000005, -2.712649719999945 52.976845954000055, -2.7127094429999374 52.97666122700008, -2.7127807509999684 52.97644066000004, -2.7128520589999425 52.97622009500003, -2.7129271499999277 52.97598782400007, -2.7130016339999656 52.97577982900003, -2.713080727999966 52.97556023200008, -2.7131004959999245 52.97550534800007, -2.713162729999965 52.97534102700007, -2.7132043219999673 52.975231207000036, -2.713231607999944 52.97512035200003, -2.7132504929999754 52.97504363100006, -2.7132855199999426 52.97489035800004, -2.713294191999978 52.97470740400007, -2.7132928979999633 52.97467333000003, -2.713285490999965 52.97447853500006, -2.713281368999958 52.97444876000003, -2.7132575269999393 52.97427653400007, -2.7132440829999496 52.97422527400005, -2.7131944639999688 52.97403609500003, -2.713183413999957 52.974003581000034, -2.7131108249999443 52.973795823000046, -2.713009918999944 52.973597178000034, -2.7129928239999686 52.97356975800005, -2.712893577999978 52.97341057500006, -2.712855658999956 52.97336095800006, -2.7127375179999262 52.973206366000056, -2.712692535999963 52.97315913700004, -2.7124969559999386 52.97295378700005, -2.7123140409999564 52.97277213400008, -2.7121615009999687 52.97262114900008, -2.7121204219999413 52.972580192000066, -2.7119276109999646 52.972387954000055, -2.7117909809999787 52.97225172700007, -2.7117341619999706 52.97219595200005, -2.7115391569999474 52.972004525000045, -2.711332324999944 52.97180564000007, -2.7111861179999437 52.971708300000046, -2.711092171999951 52.97164764900003, -2.7109123379999573 52.97153154500006, -2.710832259999961 52.97148694200007, -2.710566397999969 52.971338993000074, -2.7102810639999575 52.971184821000065, -2.7101171979999776 52.97109628100003, -2.710031274999949 52.97106065500003), (-2.7041128406291364 52.969019840952, -2.7042174921889948 52.968901573003116, -2.7042910863649885 52.96883647135385, -2.7043555767080174 52.968779424100944, -2.704523753472922 52.968672915493784, -2.704651442356251 52.96862325891147, -2.7048585656315045 52.968557491029244, -2.705099785502557 52.96848089526375, -2.7051916876473387 52.96845759399095, -2.705532736195302 52.9683713317477, -2.7058942333775704 52.968311893817244, -2.706093424621754 52.968279142087226, -2.706258252063803 52.9682684166648, -2.7065460078847465 52.96824969230688, -2.706628571137831 52.96824587774409, -2.7069943006218833 52.96822906691172, -2.7073647746398346 52.968218044688136, -2.7077436874954923 52.968214083534264, -2.708017806758006 52.96821121761349, -2.7081158731062636 52.96821158153305, -2.7084880969690768 52.96821296156536, -2.708633417793313 52.96821350034573, -2.708860247795888 52.96820997470726, -2.7089435787083604 52.96820867908382, -2.709145228146508 52.96819260896634, -2.7092294500994374 52.96818381784625, -2.709356612390726 52.96817054385506, -2.709584539506745 52.968119373541946, -2.7096559176582717 52.96810334850941, -2.7099355665027938 52.96801967788908, -2.71022627788591 52.967905932050115, -2.7104143401001375 52.96780746464272, -2.710512635909597 52.96775350837628, -2.710638855440608 52.967684222778274, -2.710712941828289 52.96764958447626), (-2.7041128406291364 52.969019840952, -2.7039168330420447 52.969155875591866, -2.70386910341624 52.9691896838484, -2.70381947774018 52.96922483642436, -2.7036381995932386 52.96928238607319, -2.703561428849875 52.96931178401586, -2.7034962552483717 52.96933674091039, -2.703213010418424 52.96939950238416, -2.7028695499962883 52.96947509429478, -2.702637532499264 52.96952615144353, -2.7025168488103337 52.96954646168545, -2.702436164265445 52.96956003998371, -2.7023721538444994 52.96956041779106, -2.70215695653535 52.969548737589335, -2.701784030789268 52.96950286034098, -2.701419286467941 52.96945798727543, -2.701247526612545 52.969436856533825, -2.7010546752586215 52.96941271736952, -2.7006901872137026 52.969367094423156, -2.700441891852736 52.969336013980524, -2.700325624528757 52.96932168746585, -2.6999609048455855 52.9692767441892, -2.699796192636657 52.96925644663482), (-2.710031275437483 52.97106065530996, -2.7097849738172433 52.9709585312331, -2.70972136844818 52.97093634799169, -2.7095670414523942 52.97088252439924, -2.709390076174755 52.97083449708448, -2.7093098045112134 52.97081271141644, -2.7090290117907614 52.970746838055085, -2.708695405233157 52.97067313503746, -2.7084348767204265 52.97061575330386, -2.708346394153395 52.970594994828, -2.7079946844954423 52.97051248104708, -2.707688532786224 52.970450725189814, -2.707646517839407 52.97044211145676, -2.7073009061142033 52.97037156477935, -2.7069341224397645 52.97031239582427, -2.7068636514858953 52.97030102749162, -2.7065842374246665 52.97026351448776, -2.706216081484198 52.97025122314838, -2.705845280578566 52.97025011389186, -2.705636491640781 52.97024587206619, -2.705458226517301 52.97022636383776, -2.7054046006707697 52.970220495195086, -2.70518238447235 52.970183164884624, -2.7051045496091817 52.97015957942049, -2.705009161507259 52.97013067548851, -2.704850230127376 52.97004836339108, -2.704808390524595 52.97002578531171, -2.7046813020607776 52.96995720089947, -2.704556880897668 52.96986129618569, -2.7045167202305613 52.96983033894627, -2.7043529085508147 52.96968735155019, -2.704251521199491 52.96957325142772, -2.7041798524056118 52.96947569654883, -2.704155828874296 52.96944299595623, -2.704124776670715 52.969351016848215, -2.7041144443611373 52.96924651067707, -2.7041049486665916 52.96909526460257, -2.7041128406291364 52.969019840952))
This test data, without running the geometry through my above method, renders out something like this when the geometry is placed into GeoJson:

I have highlighted red the parts of the line string I'd expect my above method to return here:

However, when I run that test data through my function, the returned piece of geometry looks like:

Note that it does crop the areas I was expecting it to, but it also has seemingly removed a chunk of the middle part of the line too. This removed middle section does contain a branch off of the main line - I'm not sure if this will have a part to play in why I am observing this.
Hi,
I have observed some unsual behaviour with the
extractLinemethod on theLocationIndexedLineobject. For the most part, it seems to work absolutely perfectly, but I have found one instance where it produces an unusual result.For context, my goal is two take three
Geometryobjects, astartPoint,endPoint, and alineString, and return a newGeometryobject that represents a cropped version of thelineStringsuch that the new line extends between the two points as well as it can.Below is an example of how I'm going about doing this:
This works fine for the most part, but I have found that with the following data it gives an unexpected result.
Repro data here as WKT. For repro these would need to be converted into Geometry objects
startPoint = POINT (-2.712395 52.984574)endPoint = POINT (-2.70684 52.968237)lineString = MULTILINESTRING ((-2.7101237699999388 52.98707844100005, -2.710402958999964 52.98692973500005, -2.7106821479999326 52.986781026000074, -2.710912693999944 52.98665822700008, -2.7109616239999355 52.98663251700003, -2.711242469999945 52.98648495200007, -2.711523313999976 52.98633738600006, -2.7115623139999343 52.98631689300004, -2.711807207999925 52.98618681600004, -2.711991945999955 52.98607945500004, -2.712064664999957 52.98601617400004, -2.7121977409999545 52.98580604300008, -2.7122973929999716 52.98560095300007, -2.7123326469999256 52.98552739400003, -2.7123847929999556 52.98538655300007, -2.712396078999973 52.985191056000076, -2.7123918649999723 52.985158271000046, -2.7123678229999655 52.98497120900004, -2.7123672129999363 52.98493410400005, -2.712366061999944 52.98486418600004, -2.7123695699999644 52.984777947000055, -2.712383562999946 52.98472071700007, -2.712382110999954 52.984674417000065, -2.7123790849999523 52.98457785200003, -2.7123761899999295 52.98448548500005, -2.712375139999949 52.984452015000045, -2.712375050999981 52.98441734000005, -2.712374873999977 52.98435167300005, -2.7123499759999277 52.984262012000045, -2.712335611999947 52.98421028100006, -2.7122960379999768 52.98404355100007, -2.7122177149999516 52.983931505000044, -2.71213851899995 52.98383595000007, -2.712117189999958 52.98381021500006, -2.712037564999946 52.98373772700006, -2.7119864009999333 52.98369885100004, -2.711925239999971 52.98365238900004, -2.711890862999951 52.98362627400007, -2.7117800889999444 52.98354212300006, -2.7117217719999758 52.983497818000046, -2.7116817479999327 52.98346742100006, -2.7114611509999804 52.98330087200003, -2.711373728999945 52.98323489100005, -2.7112355759999787 52.983122120000075, -2.7110142049999695 52.98294141700006, -2.7107928349999497 52.98276071300006, -2.710755922999965 52.982730581000055, -2.710562419999974 52.98258421500003, -2.71053324199994 52.98256225200004, -2.7104786749999334 52.98252117700008, -2.710340773999974 52.98240376800004, -2.7103153709999788 52.98238197500007, -2.7102245129999574 52.98224873100003, -2.710213759999931 52.98219512600008, -2.7102030679999416 52.98214182600003, -2.710240608999925 52.98202862100004, -2.710269933999939 52.981975927000065, -2.710321952999948 52.98188245500006, -2.7103808269999377 52.981814358000065, -2.710414913999955 52.981769565000036, -2.710516211999959 52.98163644700003, -2.7105745409999713 52.98155394300005, -2.7106516249999686 52.98144491000005, -2.7107172199999354 52.98135016900005, -2.7108013279999454 52.98122839500007, -2.710855548999973 52.98114510000005, -2.7109293769999567 52.98103168600005, -2.7109524479999436 52.980996524000034, -2.7109896849999586 52.980940470000064, -2.7110173429999804 52.98089879200006, -2.711119139999937 52.98072978600004, -2.7112395049999805 52.980529818000036, -2.711372153999946 52.98030707500004, -2.711438912999938 52.98019497200005, -2.711508561999949 52.98009809900003, -2.7116170969999303 52.97994714100008, -2.711639396999942 52.97988850100006, -2.7117020879999245 52.979723645000036, -2.711720889999981 52.97966923200005, -2.7117969069999504 52.97944923800003, -2.7118460239999536 52.979307092000056), (-2.7118460239999536 52.979307092000056, -2.7118760659999452 52.97922015000006, -2.7119206319999307 52.97908692500005, -2.7119943169999488 52.97886664400005, -2.712068001999967 52.97864636200006, -2.71208732599996 52.97858859400003, -2.71213967999995 52.978425841000046, -2.712210640999956 52.97820523300004, -2.7122816029999512 52.97798462600008, -2.7123525629999676 52.97776401900006, -2.7123872399999414 52.977656212000056, -2.7124237719999655 52.97754344200007, -2.7124952189999476 52.97732289100003, -2.7125666649999403 52.97710234200008, -2.712638110999933 52.97688179000005, -2.712649719999945 52.976845954000055, -2.7127094429999374 52.97666122700008, -2.7127807509999684 52.97644066000004, -2.7128520589999425 52.97622009500003, -2.7129271499999277 52.97598782400007, -2.7130016339999656 52.97577982900003, -2.713080727999966 52.97556023200008, -2.7131004959999245 52.97550534800007, -2.713162729999965 52.97534102700007, -2.7132043219999673 52.975231207000036, -2.713231607999944 52.97512035200003, -2.7132504929999754 52.97504363100006, -2.7132855199999426 52.97489035800004, -2.713294191999978 52.97470740400007, -2.7132928979999633 52.97467333000003, -2.713285490999965 52.97447853500006, -2.713281368999958 52.97444876000003, -2.7132575269999393 52.97427653400007, -2.7132440829999496 52.97422527400005, -2.7131944639999688 52.97403609500003, -2.713183413999957 52.974003581000034, -2.7131108249999443 52.973795823000046, -2.713009918999944 52.973597178000034, -2.7129928239999686 52.97356975800005, -2.712893577999978 52.97341057500006, -2.712855658999956 52.97336095800006, -2.7127375179999262 52.973206366000056, -2.712692535999963 52.97315913700004, -2.7124969559999386 52.97295378700005, -2.7123140409999564 52.97277213400008, -2.7121615009999687 52.97262114900008, -2.7121204219999413 52.972580192000066, -2.7119276109999646 52.972387954000055, -2.7117909809999787 52.97225172700007, -2.7117341619999706 52.97219595200005, -2.7115391569999474 52.972004525000045, -2.711332324999944 52.97180564000007, -2.7111861179999437 52.971708300000046, -2.711092171999951 52.97164764900003, -2.7109123379999573 52.97153154500006, -2.710832259999961 52.97148694200007, -2.710566397999969 52.971338993000074, -2.7102810639999575 52.971184821000065, -2.7101171979999776 52.97109628100003, -2.710031274999949 52.97106065500003), (-2.7041128406291364 52.969019840952, -2.7042174921889948 52.968901573003116, -2.7042910863649885 52.96883647135385, -2.7043555767080174 52.968779424100944, -2.704523753472922 52.968672915493784, -2.704651442356251 52.96862325891147, -2.7048585656315045 52.968557491029244, -2.705099785502557 52.96848089526375, -2.7051916876473387 52.96845759399095, -2.705532736195302 52.9683713317477, -2.7058942333775704 52.968311893817244, -2.706093424621754 52.968279142087226, -2.706258252063803 52.9682684166648, -2.7065460078847465 52.96824969230688, -2.706628571137831 52.96824587774409, -2.7069943006218833 52.96822906691172, -2.7073647746398346 52.968218044688136, -2.7077436874954923 52.968214083534264, -2.708017806758006 52.96821121761349, -2.7081158731062636 52.96821158153305, -2.7084880969690768 52.96821296156536, -2.708633417793313 52.96821350034573, -2.708860247795888 52.96820997470726, -2.7089435787083604 52.96820867908382, -2.709145228146508 52.96819260896634, -2.7092294500994374 52.96818381784625, -2.709356612390726 52.96817054385506, -2.709584539506745 52.968119373541946, -2.7096559176582717 52.96810334850941, -2.7099355665027938 52.96801967788908, -2.71022627788591 52.967905932050115, -2.7104143401001375 52.96780746464272, -2.710512635909597 52.96775350837628, -2.710638855440608 52.967684222778274, -2.710712941828289 52.96764958447626), (-2.7041128406291364 52.969019840952, -2.7039168330420447 52.969155875591866, -2.70386910341624 52.9691896838484, -2.70381947774018 52.96922483642436, -2.7036381995932386 52.96928238607319, -2.703561428849875 52.96931178401586, -2.7034962552483717 52.96933674091039, -2.703213010418424 52.96939950238416, -2.7028695499962883 52.96947509429478, -2.702637532499264 52.96952615144353, -2.7025168488103337 52.96954646168545, -2.702436164265445 52.96956003998371, -2.7023721538444994 52.96956041779106, -2.70215695653535 52.969548737589335, -2.701784030789268 52.96950286034098, -2.701419286467941 52.96945798727543, -2.701247526612545 52.969436856533825, -2.7010546752586215 52.96941271736952, -2.7006901872137026 52.969367094423156, -2.700441891852736 52.969336013980524, -2.700325624528757 52.96932168746585, -2.6999609048455855 52.9692767441892, -2.699796192636657 52.96925644663482), (-2.710031275437483 52.97106065530996, -2.7097849738172433 52.9709585312331, -2.70972136844818 52.97093634799169, -2.7095670414523942 52.97088252439924, -2.709390076174755 52.97083449708448, -2.7093098045112134 52.97081271141644, -2.7090290117907614 52.970746838055085, -2.708695405233157 52.97067313503746, -2.7084348767204265 52.97061575330386, -2.708346394153395 52.970594994828, -2.7079946844954423 52.97051248104708, -2.707688532786224 52.970450725189814, -2.707646517839407 52.97044211145676, -2.7073009061142033 52.97037156477935, -2.7069341224397645 52.97031239582427, -2.7068636514858953 52.97030102749162, -2.7065842374246665 52.97026351448776, -2.706216081484198 52.97025122314838, -2.705845280578566 52.97025011389186, -2.705636491640781 52.97024587206619, -2.705458226517301 52.97022636383776, -2.7054046006707697 52.970220495195086, -2.70518238447235 52.970183164884624, -2.7051045496091817 52.97015957942049, -2.705009161507259 52.97013067548851, -2.704850230127376 52.97004836339108, -2.704808390524595 52.97002578531171, -2.7046813020607776 52.96995720089947, -2.704556880897668 52.96986129618569, -2.7045167202305613 52.96983033894627, -2.7043529085508147 52.96968735155019, -2.704251521199491 52.96957325142772, -2.7041798524056118 52.96947569654883, -2.704155828874296 52.96944299595623, -2.704124776670715 52.969351016848215, -2.7041144443611373 52.96924651067707, -2.7041049486665916 52.96909526460257, -2.7041128406291364 52.969019840952))This test data, without running the geometry through my above method, renders out something like this when the geometry is placed into GeoJson:

I have highlighted red the parts of the line string I'd expect my above method to return here:

However, when I run that test data through my function, the returned piece of geometry looks like:

Note that it does crop the areas I was expecting it to, but it also has seemingly removed a chunk of the middle part of the line too. This removed middle section does contain a branch off of the main line - I'm not sure if this will have a part to play in why I am observing this.
Apologies in advance if this is an issue with my
Geometryobjects or underlying data, or if this approach to achieve what I am trying is ill-advised. For a lot of the other data I am testing with this approach has been working as expected though so my assumption is there might be a bug lurking in the library somewhere?I will hopefully have some time to dig into the lib myself over the coming days or weeks to see is I can track down what the issue is but just wanted to post it here in the meantime in case someone is already aware of this or is able to identify the problem quicker than myself.