Placemark - bad XML "synchronization"

Topics: Bugs
Apr 15, 2011 at 4:05 PM

A placemark not seem to be very good "synchronised" with ints XmlData content.

Eg, doing a debug, a placemark value:

pm    {GMap.NET.Placemark}    GMap.NET.Placemark

Accuracy    8    int
Address    "8 Rue Buffon, 75005 Paris, France"    string
AdministrativeAreaName    null    string
CountryName    "France"    string
CountryNameCode    "FR"    string
LocalityName    null    string
PostalCodeNumber    null    string
Status    G_GEO_SUCCESS    GMap.NET.GeoCoderStatusCode
SubAdministrativeAreaName    null    string
ThoroughfareName    null    string
XmlData    "<Placemark id=\"p1\" xmlns=\"http://earth.google.com/kml/2.0\"><address>8 Rue Buffon, 75005 Paris, France</address><AddressDetails Accuracy=\"8\" xmlns=\"urn:oasis:names:tc:ciq:xsdschema:xAL:2.0\"><Country><CountryNameCode>FR</CountryNameCode><CountryName>France</CountryName><AdministrativeArea><AdministrativeAreaName>Île-de-France</AdministrativeAreaName><SubAdministrativeArea><SubAdministrativeAreaName>Paris</SubAdministrativeAreaName><Locality><LocalityName>Paris</LocalityName><Thoroughfare><ThoroughfareName>8 Rue Buffon</ThoroughfareName></Thoroughfare><PostalCode><PostalCodeNumber>75005</PostalCodeNumber></PostalCode></Locality></SubAdministrativeArea></AdministrativeArea></Country></AddressDetails><ExtendedData><LatLonBox north=\"48.8460240\" south=\"48.8397288\" east=\"2.3652732\" west=\"2.3589780\" /></ExtendedData><Point><coordinates>2.3621256,48.8428764,0</coordinates></Point></Placemark>"    string

Apr 18, 2011 at 10:59 AM

I (serhio) created a branch in Mercurial to fix this bug, and updated some changes.... not sure If I did all correct?

Could someone from the dev team confirm that the branch is visible and "mergeable"?

thanks!

Coordinator
Apr 18, 2011 at 11:01 AM

you need to push your changes to your fork( https://hg01.codeplex.com/forks/serhhio/placemark ), currently it's empty

Apr 18, 2011 at 11:12 AM
Edited Apr 18, 2011 at 11:12 AM

@radioman:

I created a branch "PlaceMark Update"
Can now I "move" this branch to the indicated Fork?

Coordinator
Apr 18, 2011 at 11:18 AM

? you just need to push your changes to your fork, one button click action

Apr 18, 2011 at 11:26 AM
Edited Apr 18, 2011 at 11:36 AM

it asks me for authentification. So, I don't know user/password...

Coordinator
Apr 18, 2011 at 11:38 AM

i don't know your codeplex password too ;}

Apr 18, 2011 at 11:40 AM

"codeplex".

I sing-in with the Windows Live ID, using my gmail email .... Should I create a codePlex account in that case?

Coordinator
Apr 18, 2011 at 11:51 AM

 if it doesn't work with live id, i guess thats the only option

Apr 18, 2011 at 12:02 PM
Edited Apr 18, 2011 at 12:08 PM

now, authentification is OK, but it tells me "Bad gateway"...

% hg --repository D:\Projets\greatmaps push --force --new-branch https://hg01.codeplex.com/forks/gserhio/placemark
pushing to https://hg01.codeplex.com/forks/gserhio/placemark
searching for changes
http authorization required
realm: hg01.codeplex.com
HTTP Error: 502 (Bad Gateway)
[command returned code 255 Mon Apr 18 14:04:12 2011]

Coordinator
Apr 18, 2011 at 12:34 PM

o.O tried again?

Apr 18, 2011 at 1:00 PM

yee!!!! worked

Coordinator
Apr 18, 2011 at 1:10 PM

still, can't see anything new ;/

Coordinator
Apr 18, 2011 at 1:58 PM

ok, thanks ;}

Jul 8, 2011 at 2:54 PM

Hi,

I have this problem with version 1.5.5.5 published the 27 april 2011.
The bug seems fixed from 18 april.

How to do ?

Thanks

Coordinator
Jul 8, 2011 at 3:19 PM

xml format isn't so constant so it doesn't work always, feel free to correct it

Jul 10, 2011 at 4:01 PM

I am willing to fix it. What function of what class should I change ?

Coordinator
Jul 10, 2011 at 4:20 PM

debug, find out

Jul 11, 2011 at 10:16 AM

I do changes in GetPlacemarkFromReverseGeocoderUrl function of GMaps class (version 1.5.5.5), replacing the foreach loop of Placemark tags. I kept style of code, but completed and optimized it by using a new local variable nnd representing the AddressDetails tag. It seems to works fine.

foreach(XmlNode n in l)
{
	XmlNode nnd, nn = n.SelectSingleNode("//sm:Placemark/sm:address", nsMgr);
	if (nn != null)
	{
		ret = new Placemark(nn.InnerText);
		ret.XmlData = n.OuterXml;

		nn = n.SelectSingleNode("//sm:Status/sm:code", nsMgr);
		if (nn != null)
		{
			ret.Status = (GeoCoderStatusCode)int.Parse(nn.InnerText);
		}

		nnd = n.SelectSingleNode("sn:AddressDetails", nsMgr);
		if (nnd != null)
		{
			nn = nnd.SelectSingleNode("@Accuracy", nsMgr);
			if (nn != null)
			{
				ret.Accuracy = int.Parse(nn.InnerText);
			}

			nn = nnd.SelectSingleNode("sn:Country/sn:CountryNameCode", nsMgr);
			if (nn != null)
			{
				ret.CountryNameCode = nn.InnerText;
			}

			nn = nnd.SelectSingleNode("sn:Country/sn:CountryName", nsMgr);
			if (nn != null)
			{
				ret.CountryName = nn.InnerText;
			}

			nn = nnd.SelectSingleNode("//sn:AdministrativeArea/sn:AdministrativeAreaName", nsMgr);
			if (nn != null)
			{
				ret.AdministrativeAreaName = nn.InnerText;
			}

			nn = nnd.SelectSingleNode("//sn:SubAdministrativeArea/sn:SubAdministrativeAreaName", nsMgr);
			if (nn != null)
			{
				ret.SubAdministrativeAreaName = nn.InnerText;
			}

			nn = nnd.SelectSingleNode("//sn:Locality/sn:Thoroughfare/sn:ThoroughfareName", nsMgr);
			if (nn != null)
			{
				ret.ThoroughfareName = nn.InnerText;
			}

			nn = nnd.SelectSingleNode("//sn:Locality/sn:LocalityName", nsMgr);
			if (nn != null)
			{
				ret.LocalityName = nn.InnerText;
			}

			nn = nnd.SelectSingleNode("//sn:Locality/sn:PostalCode/sn:PostalCodeNumber", nsMgr);
			if (nn != null)
			{
				ret.PostalCodeNumber = nn.InnerText;
			}
		}
	}
	break;
}

Coordinator
Jul 11, 2011 at 4:21 PM

did you tested it using various places?

Jul 13, 2011 at 10:42 PM

I did more tests and met a problem with England. The Locality tag is not always present, and can be replaced by a DependentLocality tag. Then I found a bug with the XPath expressions : start path by // is a bad idea as the searched tag can be anywhere in the document and not only in the current Placemark tag. For example, with England, sometimes the first Placemark tag has no Locality tag, but the second Placemark tag have one : and this tag is found by the Xpath expression.

So I changed the Xpath expression and replaced // by appropriated expression.

Here is a code that works fine. I tested it using various places in many countries : France, Italy, Belgium, England, United States, Lithuania, Estonia, Denmark. It worked for all (just locality was not got for Estonia, but it was normal as there was not Locality tag).

foreach(XmlNode n in l)
{
	XmlNode nnd, nnl, nn = n.SelectSingleNode("sm:address", nsMgr);
	if (nn != null)
	{
		ret = new Placemark(nn.InnerText);
		ret.XmlData = n.OuterXml;

		nn = n.SelectSingleNode("//sm:Status/sm:code", nsMgr);
		if (nn != null)
		{
			ret.Status = (GeoCoderStatusCode)int.Parse(nn.InnerText);
		}

		nnd = n.SelectSingleNode("sn:AddressDetails", nsMgr);
		if (nnd != null)
		{
			nn = nnd.SelectSingleNode("@Accuracy", nsMgr);
			if (nn != null)
			{
				ret.Accuracy = int.Parse(nn.InnerText);
			}

			nn = nnd.SelectSingleNode("sn:Country/sn:CountryNameCode", nsMgr);
			if (nn != null)
			{
				ret.CountryNameCode = nn.InnerText;
			}

			nn = nnd.SelectSingleNode("sn:Country/sn:CountryName", nsMgr);
			if (nn != null)
			{
				ret.CountryName = nn.InnerText;
			}

			nn = nnd.SelectSingleNode("descendant::sn:AdministrativeArea/sn:AdministrativeAreaName", nsMgr);
			if (nn != null)
			{
				ret.AdministrativeAreaName = nn.InnerText;
			}

			nn = nnd.SelectSingleNode("descendant::sn:SubAdministrativeArea/sn:SubAdministrativeAreaName", nsMgr);
			if (nn != null)
			{
				ret.SubAdministrativeAreaName = nn.InnerText;
			}

			// Locality or DependentLocality tag ?
			nnl = nnd.SelectSingleNode("descendant::sn:Locality", nsMgr) ?? nnd.SelectSingleNode("descendant::sn:DependentLocality", nsMgr);
			if (nnl != null)
			{
				nn = nnl.SelectSingleNode(String.Format("sn:{0}Name", nnl.Name), nsMgr);
				if (nn != null)
				{
					ret.LocalityName = nn.InnerText;
				}

				nn = nnl.SelectSingleNode("sn:Thoroughfare/sn:ThoroughfareName", nsMgr);
				if (nn != null)
				{
					ret.ThoroughfareName = nn.InnerText;
				}

				nn = nnl.SelectSingleNode("sn:PostalCode/sn:PostalCodeNumber", nsMgr);
				if (nn != null)
				{
					ret.PostalCodeNumber = nn.InnerText;
				}
			}
		}
	}
	break;
}

Coordinator
Jul 14, 2011 at 7:32 AM

thanks!, i'll try it and update code if it's good

Coordinator
Jul 25, 2011 at 7:02 PM

code updated, thx

Jul 27, 2011 at 3:02 PM

Perfect. It was a pleasure.