Skip to content

Commit 53783f8

Browse files
dfyxchadly
authored andcommitted
Implement Geocoding through HERE (chadly#112)
* Implement Geocoding through HERE * Update README * Some code cleanups * Add some error handling
1 parent 9afd9a8 commit 53783f8

14 files changed

Lines changed: 598 additions & 1 deletion

Geocoding.sln

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Geocoding.Yahoo", "src\Geoc
1717
EndProject
1818
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Geocoding.Tests", "test\Geocoding.Tests\Geocoding.Tests.csproj", "{B87FBD8D-1E79-49F0-B06D-B4B15C1BA9C4}"
1919
EndProject
20+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Geocoding.Here", "src\Geocoding.Here\Geocoding.Here.csproj", "{41F9E0D3-2094-4CE7-A2CD-F3CAF585A048}"
21+
EndProject
2022
Global
2123
GlobalSection(SolutionConfigurationPlatforms) = preSolution
2224
Debug|Any CPU = Debug|Any CPU
@@ -47,6 +49,10 @@ Global
4749
{B87FBD8D-1E79-49F0-B06D-B4B15C1BA9C4}.Debug|Any CPU.Build.0 = Debug|Any CPU
4850
{B87FBD8D-1E79-49F0-B06D-B4B15C1BA9C4}.Release|Any CPU.ActiveCfg = Release|Any CPU
4951
{B87FBD8D-1E79-49F0-B06D-B4B15C1BA9C4}.Release|Any CPU.Build.0 = Release|Any CPU
52+
{41F9E0D3-2094-4CE7-A2CD-F3CAF585A048}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
53+
{41F9E0D3-2094-4CE7-A2CD-F3CAF585A048}.Debug|Any CPU.Build.0 = Debug|Any CPU
54+
{41F9E0D3-2094-4CE7-A2CD-F3CAF585A048}.Release|Any CPU.ActiveCfg = Release|Any CPU
55+
{41F9E0D3-2094-4CE7-A2CD-F3CAF585A048}.Release|Any CPU.Build.0 = Release|Any CPU
5056
EndGlobalSection
5157
GlobalSection(SolutionProperties) = preSolution
5258
HideSolutionNode = FALSE
@@ -56,6 +62,10 @@ Global
5662
{B46F0315-6CE4-414A-BDDA-186090F5062C} = {F742864D-9400-4CE2-957A-DBD0A0237277}
5763
{27F58640-D424-40F5-945E-42BF8BC872A0} = {F742864D-9400-4CE2-957A-DBD0A0237277}
5864
{9773C7DA-DD1A-490D-B4D8-CEA18804AD1E} = {F742864D-9400-4CE2-957A-DBD0A0237277}
65+
{41F9E0D3-2094-4CE7-A2CD-F3CAF585A048} = {F742864D-9400-4CE2-957A-DBD0A0237277}
66+
EndGlobalSection
67+
GlobalSection(ExtensibilityGlobals) = postSolution
68+
SolutionGuid = {085E97E6-56E0-4099-94E9-10F9080F2DD1}
5969
EndGlobalSection
6070
GlobalSection(MonoDevelopProperties) = preSolution
6171
StartupItem = Tests\Tests.csproj

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ Includes a model and interface for communicating with five popular Geocoding pro
77
* [Bing Maps (aka Virtual Earth)](http://www.microsoft.com/maps/) - [docs](http://msdn.microsoft.com/en-us/library/ff701715.aspx)
88
* :warning: MapQuest [(Commercial API)](http://www.mapquestapi.com/) - [docs](http://www.mapquestapi.com/geocoding/)
99
* :warning: MapQuest [(OpenStreetMap)](http://open.mapquestapi.com/) - [docs](http://open.mapquestapi.com/geocoding/)
10+
* [HERE](https://www.here.com/) - [docs](https://developer.here.com/documentation)
1011

1112
The API returns latitude/longitude coordinates and normalized address information. This can be used to perform address validation, real time mapping of user-entered addresses, distance calculations, and much more.
1213

@@ -29,6 +30,7 @@ Install-Package Geocoding.Google
2930
Install-Package Geocoding.MapQuest
3031
Install-Package Geocoding.Microsoft
3132
Install-Package Geocoding.Yahoo
33+
Install-Package Geocoding.Here
3234
```
3335

3436
## Example Usage
@@ -71,6 +73,8 @@ You will need a [consumer secret and consumer key](http://developer.yahoo.com/bo
7173

7274
MapQuest API requires a key. Sign up here: (http://developer.mapquest.com/web/products/open)
7375

76+
HERE requires an [app ID and app Code](https://developer.here.com/?create=Freemium-Basic&keepState=true&step=account)
77+
7478
## How to Build from Source
7579

7680
```
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
3+
<PropertyGroup>
4+
<Description>Includes a model and interface for communicating with four popular Geocoding providers. Current implementations include: Google Maps, Yahoo! PlaceFinder, Bing Maps (aka Virtual Earth), and Mapquest. The API returns latitude/longitude coordinates and normalized address information. This can be used to perform address validation, real time mapping of user-entered addresses, distance calculations, and much more.</Description>
5+
<AssemblyTitle>Geocoding.net Google</AssemblyTitle>
6+
<VersionPrefix>4.0.0-beta1</VersionPrefix>
7+
<Authors>chadly</Authors>
8+
<TargetFrameworks>netstandard1.3;net46</TargetFrameworks>
9+
<AssemblyName>Geocoding.Here</AssemblyName>
10+
<PackageId>Geocoding.Google</PackageId>
11+
<PackageTags>geocoding;geocode;geocoder;maps;address;validation;normalization;google-maps;bing-maps;yahoo-placefinder;mapquest</PackageTags>
12+
<PackageReleaseNotes>https://github.com/chadly/Geocoding.net/releases/latest</PackageReleaseNotes>
13+
<PackageProjectUrl>https://github.com/chadly/Geocoding.net</PackageProjectUrl>
14+
<PackageLicenseUrl>https://github.com/chadly/Geocoding.net/blob/master/LICENSE</PackageLicenseUrl>
15+
<Version>4.0.0</Version>
16+
<RepositoryUrl>https://github.com/chadly/Geocoding.net.git</RepositoryUrl>
17+
<RepositoryType>git</RepositoryType>
18+
</PropertyGroup>
19+
20+
<ItemGroup>
21+
<ProjectReference Include="..\Geocoding.Core\Geocoding.Core.csproj" />
22+
</ItemGroup>
23+
24+
<ItemGroup>
25+
<PackageReference Include="Newtonsoft.Json" Version="9.0.1" />
26+
</ItemGroup>
27+
28+
<ItemGroup Condition="'$(TargetFramework)'=='netstandard1.3'">
29+
<PackageReference Include="System.Net.Http" Version="4.3.1" />
30+
<PackageReference Include="System.Runtime.Serialization.Json" Version="4.3.0" />
31+
</ItemGroup>
32+
33+
<ItemGroup Condition="'$(TargetFramework)'=='net46'">
34+
<Reference Include="System.Net.Http" />
35+
</ItemGroup>
36+
37+
</Project>

src/Geocoding.Here/HereAddress.cs

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
using System;
2+
3+
namespace Geocoding.Here
4+
{
5+
public class HereAddress : Address
6+
{
7+
readonly string street, houseNumber, city, state, country, postalCode;
8+
readonly HereLocationType type;
9+
10+
public string AddressLine
11+
{
12+
get { return street ?? ""; }
13+
}
14+
15+
public string AdminDistrict
16+
{
17+
get { return houseNumber ?? ""; }
18+
}
19+
20+
public string AdminDistrict2
21+
{
22+
get { return city ?? ""; }
23+
}
24+
25+
public string CountryRegion
26+
{
27+
get { return state ?? ""; }
28+
}
29+
30+
public string Neighborhood
31+
{
32+
get { return country ?? ""; }
33+
}
34+
35+
public string PostalCode
36+
{
37+
get { return postalCode ?? ""; }
38+
}
39+
40+
public HereLocationType Type
41+
{
42+
get { return type; }
43+
}
44+
45+
public HereAddress(string formattedAddress, Location coordinates, string street, string houseNumber, string city,
46+
string state, string postalCode, string country, HereLocationType type)
47+
: base(formattedAddress, coordinates, "HERE")
48+
{
49+
this.street = street;
50+
this.houseNumber = houseNumber;
51+
this.city = city;
52+
this.state = state;
53+
this.postalCode = postalCode;
54+
this.country = country;
55+
this.type = type;
56+
}
57+
}
58+
}

0 commit comments

Comments
 (0)