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

Issue parsing coordinates #1

Closed
seang96 opened this issue Nov 12, 2017 · 4 comments
Closed

Issue parsing coordinates #1

seang96 opened this issue Nov 12, 2017 · 4 comments

Comments

@seang96
Copy link

seang96 commented Nov 12, 2017

I am getting an exception thrown on a specific kml file trying to read coordinates. Apparently it has null values which are not supported.

Error output:

System.Xml.XmlException
'.', hexadecimal value 0x00, is an invalid character. Line 64, position 4127.
   at System.Xml.XmlTextReaderImpl.Throw(Exception e)
   at System.Xml.XmlTextReaderImpl.ParseText(Int32& startPos, Int32& endPos, Int32& outOrChars)
   at System.Xml.XmlTextReaderImpl.FinishPartialValue()
   at System.Xml.XmlTextReaderImpl.get_Value()
   at SharpKml.Base.Parser.GetElement()
   at SharpKml.Base.Parser.AddChild(Element parent)
   at SharpKml.Base.Parser.GetElement()
   at SharpKml.Base.Parser.AddChild(Element parent)
   at SharpKml.Base.Parser.GetElement()
   at SharpKml.Base.Parser.AddChild(Element parent)
   at SharpKml.Base.Parser.GetElement()
   at SharpKml.Base.Parser.AddChild(Element parent)
   at SharpKml.Base.Parser.GetElement()
   at SharpKml.Base.Parser.Parse(XmlReader reader)
   at SharpKml.Base.Parser.ParseString(String xml, Boolean namespaces)

Coordinate from KML:

<coordinates>
				-79.98320192098618,42.11999533185155,0 -79.98312145471573,42.11997742628947,0 -79.98305909335613,42.1199903580848,0 -79.9829987436533,42.12002766132579,0 -79.98301081359386,42.12007839369832,0 -79.98317241668701,42.12035145253511,0 -79.98323678970337,42.12044495875157,0 -79.98341113328934,42.12103384579484,0 -79.98314023017883,42.12107761420794,0 -79.98231276869774,42.12123179814957,0 -79.9813511967659,42.12139095537324,0 -79.98083889484406,42.12148048113586,0 -79.98079732060432,42.12168340572951,0 -79.98077385127544,42.12231803825434,0 -79.98076379299164,42.12314563726372,0 -79.98073227703571,42.12336894788482,0 -79.98123049736023,42.12353655467135,0 -79.98261451721191,42.1239901352054,0 -79.98321197926998,42.12420150660386,0 -79.9835479259491,42.12432832910445,0 -79.98536109924316,42.12492513746361,0 -79.98586535453796,42.12508030671614,0 -79.98620867729187,42.12515192316603,0 -79.98654127120972,42.125199667421,0 -79.98688995838165,42.12522751821977,0 -79.98720645904541,42.12523945427265,0 -79.98755514621735,42.12523547558861,0 -79.98784482479096,42.12521956084996,0 -79.98834908008575,42.12511412560534,0 -79.9887353181839,42.12504847715685,0 -79.99017298221588,42.12456705312274,0 -79.99111711978912,42.12424477548553,0 -79.99154627323151,42.12410551920914,0 -79.99181985855103,42.12402992281665,0 -79.99203979969025,42.12398615644292,0 -79.99229192733765,42.12392249620898,0 -79.99252259731293,42.12389862360476,0 -79.99381542205811,42.123771302897,0 -79.99515116214752,42.1236479607174,0 -79.99709844589233,42.1234848303691,0 -79.99883651733398,42.1233495512251,0 -79.99927639961243,42.12397422015391,0 -79.99960362911224,42.12443973375826,0 -79.99992549419403,42.12483362721345,0 -80.00020444393158,42.12506439193848,0 -80.0008749961853,42.12555376952228,0 -80.00144362449646,42.12538666540649,0 -80.00283300876617,42.12498083929029,0 -80.00432431697846,42.12451135093225,0 -80.00607311725617,42.12395432633393,0 -80.00814378261566,42.12330180557593,0 -80.00925958156586,42.12295962737046,0 -80.01046121120453,42.12259357422108,0 -80.01118004322052,42.12236677936097,0 -80.01350283622742,42.1216704742797,0 -80.01652836799622,42.12075531882135,0 -80.02203494310379,42.11872203482449,0 -80.02707213163376,42.11687570868919,0 -80.02922058105469,42.11606792408963,0 -80.03668516874313,42.11331222674014,0 -80.03909379243851,42.11242281725451,0 -80.04043757915497,42.11452395246425,0 -80.04168748855591,42.11642804608204,0 -80.04329413175583,42.11888716697658,0 -80.04432410001755,42.12046684316526,0 -80.04400491714478,42.12060411795161,0 -80.04283010959625,42.12104379316411,0 -80.04274159669876,42.12112934047534,0 -80.04151582717896,42.121551106926,0 -80.03998696804047,42.12210815265259,0 -80.03916084766388,42.12239065254235,0 -80.03949075937271,42.12290591318202,0 -80.03954708576202,42.12293774381768,0 -80.03965705633164,42.12290392376674,0 -80.0397053360939,42.12243243058817,0 -80.03996014595032,42.122348874469,0 -80.04130125045776,42.12243839887817,0 -80.0425136089325,42.12253588086874,0 -80.04253506660461,42.12234091673763,0 -80.04269868135452,42.12223945557491,0 -80.04322707653046,42.12206836383452,0 -80.04382789134979,42.12300339445327,0 -80.04419535398483,42.1227945058312,0 -80.04468888044357,42.12259755307102,0 -80.04570007324219,42.1222235400837,0 -80.04624724388123,42.12202260666287,0 -80.04717528820038,42.12167843209527,0 -80.04833936691284,42.12125268755798,0 -80.04950881004334,42.12082296119891,0 -80.05048781633377,42.12046485367343,0 -80.05208909511566,42.11987596134213,0 -80.05318880081177,42.11947009992811,0 -80.05473911762238,42.11889711468283,0 -80.05604803562164,42.11841166479585,0 -80.05756080150604,42.11786254486746,0 -80.05831182003021,42.11758798311892,0 -80.05932033061981,42.11721791974959,0 -80.06098866462708,42.11659318421189,0 -80.06176114082336,42.11631463771954,0 -80.06295204162598,42.11588288823689,0 -80.06399810314179,42.11549490808202,0 -80.06543040275574,42.11496963885703,0 -80.06666421890259,42.11450803503512,0 -80.06775856018066,42.11410611862456,0 -80.06904065608978,42.11363654968883,0 -80.06999015808106,42.11327840155176,0 -80.0712749                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   3619919,42.11280086755421,0 -80.07194817066193,42.11254618128436,0 -80.07355749607086,42.11193134849381,0 -80.07381498813629,42.11232332995876,0 -80.07434606552124,42.11310728561627,0 -80.0748074054718,42.11380766419541,0 -80.07554769515991,42.11492188689344,0 -80.07631748914719,42.11604802778731,0 -80.07670640945435,42.11662700763117,0 -80.07746815681458,42.11775112864915,0 -80.07798314094544,42.11854297537809,0 -80.07849276065826,42.11931491693579,0 -80.07924914360046,42.12044097976644,0 -80.08006453514099,42.12169434772343,0 -80.08071631193161,42.12266121463621,0 -80.0813090801239,42.12359026832515,0 -80.08193135261536,42.12452925521312,0 -80.08262604475021,42.12555774818632,0 -80.08398056030273,42.12507433867496,0 -80.08422195911408,42.12541451612304,0 -80.08456528186798,42.12594765605129,0 -80.08501589298248,42.12660810675567,0 -80.08550941944122,42.12736403585847,0 -80.0859922170639,42.12810006342298,0 -80.08635699748993,42.12867296544624,0 -80.08668154478073,42.12915435827924,0 -80.0868558883667,42.1294288699098,0 -80.08560061454773,42.12988240825823,0 -80.08469939231873,42.13022057070304,0 -80.08420586585999,42.13039959714884,0 -80.08367478847504,42.12959596336332,0 -80.0836318731308,42.12952236272979,0 -80.08321076631546,42.12897134986466,0 -80.08293449878693,42.12851581575416,0 -80.08272528648377,42.12819156895492,0 
			</coordinates>
@samcragg
Copy link
Owner

That exception looks like the XML data is malformed - can you run it through an XML validator to see if there are any issues with the data?

If that checks out ok, can you attach a minimal file that reproduces the error and I'll take a look at it.

@seang96
Copy link
Author

seang96 commented Nov 13, 2017

I checked it with a few online XML validators and it was valid every time. I attached a zip with the entire file.
file.zip

@samcragg
Copy link
Owner

I can't reproduce that error, the following works for me (.NET Core console app on Windows 10):

KmlFile kml = KmlFile.Load(File.OpenRead(FileName));

Inspecting the kml object I can see all the co-ordinates in it as well. I've also tried the ParseString method, using File.ReadAllText() and can't replicate it.

How are you getting the string and is there a null character in it?

@seang96
Copy link
Author

seang96 commented Nov 19, 2017

Through a download. My downloader was not working correctly, making this issue fixed.

@seang96 seang96 closed this as completed Nov 19, 2017
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