Skip to content

Commit

Permalink
Minor improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
Serg-Norseman committed Dec 26, 2016
1 parent 7118059 commit f039525
Show file tree
Hide file tree
Showing 5 changed files with 109 additions and 106 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

gource-gk.cmd
build_coverity.cmd
/projects/GEDKeeper2.mswin-cov.sln
sonarqube.cmd

/projects/GEDKeeper2/bin/
Expand Down
50 changes: 26 additions & 24 deletions projects/GEDKeeper2/GKCore/Geocoding/GoogleGeocoder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -56,35 +56,37 @@ private IList<GeoPoint> ParseXml(string url)
request.ContentType = "application/x-www-form-urlencoded";
request.Proxy = fProxy;

HttpWebResponse response = (HttpWebResponse)request.GetResponse();
Stream stream = response.GetResponseStream();
using (HttpWebResponse response = (HttpWebResponse)request.GetResponse()) {
using (Stream stream = response.GetResponseStream()) {

XmlDocument xmlDocument = new XmlDocument();
xmlDocument.Load(stream);
XmlNode node = xmlDocument.DocumentElement;
XmlDocument xmlDocument = new XmlDocument();
xmlDocument.Load(stream);
XmlNode node = xmlDocument.DocumentElement;

if (node != null && node.ChildNodes.Count > 0)
{
int num = node.ChildNodes.Count;
for (int i = 0; i < num; i++)
{
XmlNode xNode = node.ChildNodes[i];
if (xNode.Name == "result")
if (node != null && node.ChildNodes.Count > 0)
{
XmlNode addressNode = xNode["formatted_address"];
XmlNode geometry = xNode["geometry"];
XmlNode pointNode = geometry["location"];

if (addressNode != null && pointNode != null)
int num = node.ChildNodes.Count;
for (int i = 0; i < num; i++)
{
string ptHint = addressNode.InnerText;
double ptLongitude = SysUtils.ParseFloat(pointNode["lng"].InnerText, -1.0);
double ptLatitude = SysUtils.ParseFloat(pointNode["lat"].InnerText, -1.0);

if (ptLatitude != -1.0 && ptLongitude != -1.0)
XmlNode xNode = node.ChildNodes[i];
if (xNode.Name == "result")
{
GeoPoint gpt = new GeoPoint(ptLatitude, ptLongitude, ptHint);
geoObjects.Add(gpt);
XmlNode addressNode = xNode["formatted_address"];
XmlNode geometry = xNode["geometry"];
XmlNode pointNode = geometry["location"];

if (addressNode != null && pointNode != null)
{
string ptHint = addressNode.InnerText;
double ptLongitude = SysUtils.ParseFloat(pointNode["lng"].InnerText, -1.0);
double ptLatitude = SysUtils.ParseFloat(pointNode["lat"].InnerText, -1.0);

if (ptLatitude != -1.0 && ptLongitude != -1.0)
{
GeoPoint gpt = new GeoPoint(ptLatitude, ptLongitude, ptHint);
geoObjects.Add(gpt);
}
}
}
}
}
Expand Down
3 changes: 2 additions & 1 deletion projects/GEDKeeper2/GKCore/Geocoding/YandexGeocoder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,9 @@ private static IList<GeoPoint> ParseXml(string url)
string[] splitted = pointNode.InnerText.Split(new char[] { ' ' }, count: 2);
double lng = double.Parse(splitted[0], CultureInfo.InvariantCulture);
double lat = double.Parse(splitted[1], CultureInfo.InvariantCulture);
string ptHint = (metaNode == null) ? string.Empty : metaNode["text"].InnerText;

GeoPoint gpt = new GeoPoint(lat, lng, metaNode["text"].InnerText);
GeoPoint gpt = new GeoPoint(lat, lng, ptHint);
geoObjects.Add(gpt);
}
}
Expand Down
159 changes: 79 additions & 80 deletions projects/GEDKeeper2/GKUI/BaseWin.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion projects/GEDKeeper2/GKUI/BaseWin.cs
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@ private void contextMenu_Opening(object sender, CancelEventArgs e)

private void miRecordAdd_Click(object sender, EventArgs e)
{
this.RecordAdd();
this.RecordAdd();
}

private void miRecordEdit_Click(object sender, EventArgs e)
Expand Down

0 comments on commit f039525

Please sign in to comment.