ThinkGeo.com    |     Documentation    |     Premium Support

How to parse WKT data?

 hello forum i need only coordinates of my route ans point 


i calculate WKT of my routes 


like this



 


POINT(73.0185097465598 33.6810265037665)


 


MULTILINESTRING((73.0111429810373 33.6783008666403,73.0116544995556 33.6785708996273),(73.0119205001311 33.6783781002692,73.0118432996287 33.678392400389,73.0117917999517 33.6784137997571,73.0117403002747 33.6784638002642,73.0116544995556 33.6785708996273),(73.0131224998036 33.679001500419,73.0119635003153 33.678392400389,73.0119205001311 33.6783781002692),(73.0131224998036 33.679001500419,73.0136031002029 33.6783443999742),(73.0136031002029 33.6783443999742,73.0147099372139 33.67685138958),(73.0147099372139 33.67685138958,73.0150124997272 33.6770292997624,73.0154158996241 33.6773507003746,73.0157677998441 33.6776577999676,73.016042399737 33.6779721004322,73.0162998999205 33.6783149004124,73.0167443997343 33.6789772996627),(73.0167443997343 33.6789772996627,73.0171146002587 33.6794933999005,73.0173738999856 33.6798920001158),(73.0173738999856 33.6798920001158,73.0175952995835 33.6801933998056,73.017689300321 33.6802989001741),(73.017689300321 33.6802989001741,73.017964400237 33.680586200293,73.0185097465598 33.6810265037665))


 


MULTILINESTRING((73.0185097465598 33.6810265037665,73.0186117996948 33.681108899756),(73.0186117996948 33.681108899756,73.0186413001559 33.681120000088,73.0186946002756 33.681164699991),(73.0186946002756 33.681164699991,73.0187495002893 33.681095800231),(73.0187495002893 33.681095800231,73.0193249000242 33.6803637997496),(73.0193249000242 33.6803637997496,73.0195480002401 33.6800851996723),(73.0195480002401 33.6800851996723,73.0197712002807 33.6797852002269),(73.0197712002807 33.6797852002269,73.0200115000308 33.6794780997346),(73.0200115000308 33.6794780997346,73.020199700256 33.6792233002152),(73.020199700256 33.6792233002152,73.0206966997929 33.679470600288),(73.0209198998336 33.6791562998234,73.0206966997929 33.679470600288),(73.0211343998328 33.6788777995708,73.0209198998336 33.6791562998234),(73.0218726002404 33.6792491997908,73.0211343998328 33.6788777995708),(73.0218726002404 33.6792491997908,73.0218305002774 33.6789161997229),(73.0218305002774 33.6789161997229,73.0218210996641 33.6788205999907),(73.0218210996641 33.6788205999907,73.021797999678 33.6786753001251,73.0217789997012 33.6784876997476),(73.0217789997012 33.6784876997476,73.0217188998074 33.6780734000674),(73.0217188998074 33.6780734000674,73.0217095000934 33.6779850003076),(73.0217095000934 33.6779850003076,73.0217035996415 33.6778538998377,73.0217102995907 33.6776591003872),(73.0217102995907 33.6776591003872,73.0217008998767 33.6775563996082),(73.0217008998767 33.6775563996082,73.0217635997104 33.6773682002823,73.0217961003098 33.6773020002871),(73.0217961003098 33.6773020002871,73.0218382002728 33.6772349998954),(73.0214683032023 33.6770434798131,73.0218382002728 33.6772349998954))


but i only want coordiantes seperatly (in an array) like


a[0] =73.0185097465598;


a[1] =33.6810265037665;


a[2]= 73.0111429810373;


 


and so on


is there anyway to do this task


 


 





Hi Faryal,


You can try this code,



            MultilineShape shape = new MultilineShape(wkt);
            Collection<double> x = new Collection<double>();
            Collection<double> y = new Collection<double>();

            foreach (var line in shape.Lines)
            {
                foreach (var vertex in line.Vertices)
                {
                    x.Add(vertex.X);
                    y.Add(vertex.Y);
                }
            }

Hope it helps,


Edgar