maptp-service 0.0.1 → 0.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/History.txt +6 -0
- data/Manifest.txt +2 -4
- data/PostInstall.txt +4 -5
- data/README.rdoc +38 -2
- data/lib/maptp-service/geocoding.rb +91 -0
- data/lib/maptp-service/parser/geocoding_result.rb +83 -0
- data/lib/maptp-service.rb +4 -2
- data/spec/maptp-service_spec.rb +25 -1
- data/spec/spec_helper.rb +0 -1
- metadata +13 -16
- data/nbproject/private/private.properties +0 -2
- data/nbproject/private/rake-d.txt +0 -48
- data/nbproject/project.properties +0 -7
- data/nbproject/project.xml +0 -15
data/History.txt
CHANGED
data/Manifest.txt
CHANGED
@@ -4,12 +4,10 @@ PostInstall.txt
|
|
4
4
|
README.rdoc
|
5
5
|
Rakefile
|
6
6
|
lib/maptp-service.rb
|
7
|
+
lib/maptp-service/parser/geocoding_result.rb
|
8
|
+
lib/maptp-service/geocoding.rb
|
7
9
|
lib/maptp-service/parser/route.rb
|
8
10
|
lib/maptp-service/routing.rb
|
9
|
-
nbproject/private/private.properties
|
10
|
-
nbproject/private/rake-d.txt
|
11
|
-
nbproject/project.properties
|
12
|
-
nbproject/project.xml
|
13
11
|
script/console
|
14
12
|
script/destroy
|
15
13
|
script/generate
|
data/PostInstall.txt
CHANGED
@@ -1,7 +1,6 @@
|
|
1
1
|
|
2
|
-
For more information on maptp-service, see http://maptp-service
|
3
|
-
|
4
|
-
NOTE: Change this information in PostInstall.txt
|
5
|
-
You can also delete it if you don't want it.
|
6
|
-
|
2
|
+
For more information on maptp-service, see http://github.com/ffwdme/maptp-service
|
7
3
|
|
4
|
+
Note:
|
5
|
+
This is not an official client of MapTP or NAVTEQ.
|
6
|
+
I you're looking for the official clients/APIs head over to http://www.nn4d.com
|
data/README.rdoc
CHANGED
@@ -2,7 +2,11 @@
|
|
2
2
|
|
3
3
|
== FINALLY, A RUBY CLIENT FOR MAP TP!
|
4
4
|
|
5
|
-
|
5
|
+
Repository: http://github.com/ffwdme/maptp-service
|
6
|
+
|
7
|
+
Gem: http://rubygems.org/gems/maptp-service
|
8
|
+
|
9
|
+
Bug Tracker: http://github.com/ffwdme/maptp-service/issues
|
6
10
|
|
7
11
|
== DESCRIPTION:
|
8
12
|
|
@@ -12,20 +16,43 @@ In order to use them, you need your MapTP credentials aka your Map24 id.
|
|
12
16
|
|
13
17
|
For more information head over to http://www.nn4d.com
|
14
18
|
|
19
|
+
You should consider that this client solely works with WGS´84 coordinates in the Decimal Degrees format.
|
20
|
+
Usually MapTP services work with the Decimal Minutes format, but because Decimal Degrees are much more
|
21
|
+
established we use it for this lib. To work with MapTP the parameters as well as the responses are
|
22
|
+
converted internally.
|
23
|
+
|
15
24
|
*Note*: This is *not* an official client of MapTP or NAVTEQ, but a private project. :)
|
16
25
|
|
17
26
|
== FEATURES/PROBLEMS:
|
18
27
|
|
19
|
-
*
|
28
|
+
* A very simple routing request (takes not much options).
|
29
|
+
* Free search for geocoding.
|
20
30
|
* more to come...
|
21
31
|
|
22
32
|
== SYNOPSIS:
|
23
33
|
|
34
|
+
=== Setup
|
35
|
+
|
24
36
|
First of all you need to provide your MapTP credentials.
|
25
37
|
For example if your Map24 id is "123ABC" and bound to the server maptp12.map24.com you'll enter
|
26
38
|
|
27
39
|
MapTP.set_credentials '123ABC', 'maptp12'
|
28
40
|
|
41
|
+
=== Geocoding (free search)
|
42
|
+
|
43
|
+
Create a new geocoding object
|
44
|
+
|
45
|
+
geocoding = MapTP::Geocoding.new
|
46
|
+
|
47
|
+
Try to find addresses/points/objects matching a search term, e.g. "Times Square, New York", "Zeil Frankfurt", "Downing Street 10 London"
|
48
|
+
|
49
|
+
results = geocoding.find_coordinates_by_text("Downing Street 10 London")
|
50
|
+
|
51
|
+
This will return either a hash containing the objects found or in case something went wrong
|
52
|
+
a hash with a key ":ERROR" that holds the error informations.
|
53
|
+
|
54
|
+
=== Routing
|
55
|
+
|
29
56
|
Given, you have two coordinates to create a route for:
|
30
57
|
|
31
58
|
start_coordinate = { :lat => 49.945589, :lng => 8.845563 }
|
@@ -39,6 +66,9 @@ And try to find the matching route:
|
|
39
66
|
|
40
67
|
route = routing.find_route_by_coordinates start_coordinate, destination_coordinate
|
41
68
|
|
69
|
+
This will return either a hash containing the route informations or in case something went wrong
|
70
|
+
a hash with a key ":ERROR" that holds the error informations.
|
71
|
+
|
42
72
|
== REQUIREMENTS:
|
43
73
|
|
44
74
|
* The savon SOAP client (http://github.com/rubiii/savon)
|
@@ -51,6 +81,12 @@ And try to find the matching route:
|
|
51
81
|
|
52
82
|
In order to run the tests properly, make sure you provided your MapTP credentials as shown above.
|
53
83
|
|
84
|
+
== IMPORTANT NOTE
|
85
|
+
|
86
|
+
Again, this is not an official client of MapTP or NAVTEQ but a private project.
|
87
|
+
|
88
|
+
If you're looking for the official clients/APIs head over to http://www.nn4d.com
|
89
|
+
|
54
90
|
== LICENSE:
|
55
91
|
|
56
92
|
(The MIT License)
|
@@ -0,0 +1,91 @@
|
|
1
|
+
module MapTP
|
2
|
+
|
3
|
+
# Provides a Ruby client to the SOAP interface of the
|
4
|
+
# MapTP geocoding services (version 5.1).
|
5
|
+
#
|
6
|
+
# Should be initialized for every new geocoding request.
|
7
|
+
class Geocoding
|
8
|
+
|
9
|
+
def initialize
|
10
|
+
|
11
|
+
# Disable log output
|
12
|
+
Savon::Request.log = false
|
13
|
+
|
14
|
+
@client = Savon::Client.new "http://#{MapTP::maptp_server}.map24.com/map24/webservices1.5?soap=Map24Geocoder51"
|
15
|
+
|
16
|
+
end
|
17
|
+
|
18
|
+
# Searches for addresses and their coordinates that match the provided search query.
|
19
|
+
#
|
20
|
+
# Parameters:
|
21
|
+
#
|
22
|
+
# [+query+] The search query, e.g. "Times Square, New York", "Zeil Frankfurt", "Downing Street 10 London"
|
23
|
+
#
|
24
|
+
# [+max_number_of_alternatives+] The max number of alternatives returned by the service (default is 10)
|
25
|
+
#
|
26
|
+
# [+response_language+] The language the results shoult be localized (if possible, default is "EN" = English)
|
27
|
+
#
|
28
|
+
# Returns either a hash containing the informations or a hash with a key +:ERROR+ containing
|
29
|
+
# the error message.
|
30
|
+
def find_coordinates_by_text(query, max_number_of_alternatives = 10, response_language = "EN")
|
31
|
+
|
32
|
+
begin
|
33
|
+
|
34
|
+
response = @client.search_free! do |soap|
|
35
|
+
|
36
|
+
soap.namespaces["xmlns:SOAP-ENV"] = "http://schemas.xmlsoap.org/soap/envelope/"
|
37
|
+
soap.namespaces["xmlns:xsd"] = "http://www.w3.org/2001/XMLSchema"
|
38
|
+
soap.namespaces["xmlns:xsi"] = "http://www.w3.org/2001/XMLSchema-instance"
|
39
|
+
soap.namespaces["xmlns:wsdl"] = "Map24Geocoder51"
|
40
|
+
soap.action = 'searchFree'
|
41
|
+
soap.input = 'searchFree'
|
42
|
+
|
43
|
+
soap.body = {
|
44
|
+
|
45
|
+
"RequestHeader" => {
|
46
|
+
"Map24ID" => MapTP::map24_id
|
47
|
+
|
48
|
+
},
|
49
|
+
"MapSearchFreeRequest" => {
|
50
|
+
"SearchText" => query,
|
51
|
+
"MaxNoOfAlternatives" => max_number_of_alternatives,
|
52
|
+
"Properties" => {
|
53
|
+
"item" =>
|
54
|
+
{
|
55
|
+
"Key" => "Language",
|
56
|
+
"Value" => response_language,
|
57
|
+
}
|
58
|
+
}
|
59
|
+
}
|
60
|
+
|
61
|
+
|
62
|
+
}
|
63
|
+
|
64
|
+
end
|
65
|
+
|
66
|
+
MapTP::Parser::GeocodingResult.to_hash(response)
|
67
|
+
|
68
|
+
rescue Savon::SOAPFault => e
|
69
|
+
|
70
|
+
{ :ERROR => e.message }
|
71
|
+
|
72
|
+
|
73
|
+
rescue Savon::HTTPError => e
|
74
|
+
|
75
|
+
{ :ERROR => "HTTP Error" }
|
76
|
+
|
77
|
+
rescue SocketError
|
78
|
+
|
79
|
+
{ :ERROR => "No HTTP Connection" }
|
80
|
+
|
81
|
+
rescue
|
82
|
+
|
83
|
+
{ :ERROR => "Unknown Error" }
|
84
|
+
|
85
|
+
end
|
86
|
+
|
87
|
+
end
|
88
|
+
|
89
|
+
end
|
90
|
+
|
91
|
+
end
|
@@ -0,0 +1,83 @@
|
|
1
|
+
module MapTP
|
2
|
+
|
3
|
+
# = Namespace for parsers handling the result.
|
4
|
+
module Parser
|
5
|
+
|
6
|
+
# Parses the results of a geocoding response.
|
7
|
+
module GeocodingResult
|
8
|
+
|
9
|
+
# A hashtable containing the descriptive values
|
10
|
+
# for the hierachy property of the response.
|
11
|
+
@@hierachy_to_name = {
|
12
|
+
1 => "country",
|
13
|
+
2 => "state",
|
14
|
+
3 => "county",
|
15
|
+
4 => "city",
|
16
|
+
5 => "district",
|
17
|
+
6 => "street",
|
18
|
+
7 => "address",
|
19
|
+
8 => "zip"
|
20
|
+
}
|
21
|
+
|
22
|
+
# Parses the response to a hash
|
23
|
+
# and strips all unneccessary data
|
24
|
+
def self.to_hash(response)
|
25
|
+
|
26
|
+
resp = response.to_hash
|
27
|
+
|
28
|
+
results = resp[:search_free_response][:map_search_response][:alternatives][:item]
|
29
|
+
|
30
|
+
# Return empty array if no results are returned
|
31
|
+
return { :results => [], :ERROR => "No match found" } unless results
|
32
|
+
|
33
|
+
output = Hash.new
|
34
|
+
|
35
|
+
output[:results] = Array.new
|
36
|
+
|
37
|
+
results.each do |result|
|
38
|
+
|
39
|
+
stripped_result = Hash.new
|
40
|
+
|
41
|
+
major_properties = result[:properties_major][:item]
|
42
|
+
#minor_properties = result[:properties_minor][:item]
|
43
|
+
|
44
|
+
address = Hash.new
|
45
|
+
|
46
|
+
major_properties.each do |property|
|
47
|
+
|
48
|
+
address[:name] = property[:value] if property[:key] == "Name" # only for POIs
|
49
|
+
address[:street] = property[:value] if property[:key] == "Street"
|
50
|
+
address[:district] = property[:value] if property[:key] == "District"
|
51
|
+
address[:city] = property[:value] if property[:key] == "City"
|
52
|
+
address[:zip] = property[:value] if property[:key] == "Zip"
|
53
|
+
address[:state] = property[:value] if property[:key] == "Sta"
|
54
|
+
address[:county] = property[:value] if (property[:key] == "Cty" || property[:key] == "County")
|
55
|
+
address[:country] = property[:value] if (property[:key] == "Ctry" || property[:key] == "Country")
|
56
|
+
|
57
|
+
end
|
58
|
+
|
59
|
+
stripped_result[:address] = address
|
60
|
+
|
61
|
+
stripped_result[:type] = @@hierachy_to_name[result[:hierarchy].to_i]
|
62
|
+
stripped_result[:quality] = result[:quality].downcase
|
63
|
+
|
64
|
+
stripped_result[:coordinate] = {
|
65
|
+
:lat => result[:coordinate][:latitude].to_f / 60,
|
66
|
+
:lng => result[:coordinate][:longitude].to_f / 60
|
67
|
+
}
|
68
|
+
|
69
|
+
output[:results] << stripped_result
|
70
|
+
end
|
71
|
+
|
72
|
+
|
73
|
+
output
|
74
|
+
|
75
|
+
end
|
76
|
+
|
77
|
+
|
78
|
+
end
|
79
|
+
|
80
|
+
|
81
|
+
end
|
82
|
+
|
83
|
+
end
|
data/lib/maptp-service.rb
CHANGED
@@ -6,7 +6,9 @@ $:.unshift(File.dirname(__FILE__)) unless
|
|
6
6
|
$:.include?(File.dirname(__FILE__)) || $:.include?(File.expand_path(File.dirname(__FILE__)))
|
7
7
|
|
8
8
|
require "maptp-service/routing"
|
9
|
+
require "maptp-service/geocoding"
|
9
10
|
require "maptp-service/parser/route"
|
11
|
+
require "maptp-service/parser/geocoding_result"
|
10
12
|
|
11
13
|
# = A ruby client for MapTP services.
|
12
14
|
#
|
@@ -23,7 +25,7 @@ require "maptp-service/parser/route"
|
|
23
25
|
|
24
26
|
module MapTP
|
25
27
|
|
26
|
-
VERSION = '0.0.
|
28
|
+
VERSION = '0.0.2'
|
27
29
|
|
28
30
|
|
29
31
|
def self.set_credentials( map24id, maptp_server )
|
@@ -42,4 +44,4 @@ module MapTP
|
|
42
44
|
end
|
43
45
|
|
44
46
|
|
45
|
-
end
|
47
|
+
end
|
data/spec/maptp-service_spec.rb
CHANGED
@@ -16,6 +16,12 @@ before(:each) do
|
|
16
16
|
|
17
17
|
@routing = MapTP::Routing.new
|
18
18
|
|
19
|
+
@search_term = "Downing Street 10 London"
|
20
|
+
|
21
|
+
@wrong_search_term = "x12asd85647c asc354asc68ac asc365a4s64a8s4d65hgf4df"
|
22
|
+
|
23
|
+
@geocoding = MapTP::Geocoding.new
|
24
|
+
|
19
25
|
end
|
20
26
|
|
21
27
|
it "should calculate a route and return it as a hash" do
|
@@ -28,7 +34,7 @@ before(:each) do
|
|
28
34
|
|
29
35
|
end
|
30
36
|
|
31
|
-
it "should
|
37
|
+
it "should return an error hash when trying to resolve an impossible route" do
|
32
38
|
|
33
39
|
@wrong_route = @routing.find_route_by_coordinates @wrong_start_coordinate, @wrong_destination_coordinate
|
34
40
|
|
@@ -38,5 +44,23 @@ before(:each) do
|
|
38
44
|
|
39
45
|
end
|
40
46
|
|
47
|
+
it "should resolve a search term to geocoded adresses and return them as a hash" do
|
48
|
+
|
49
|
+
@address = @geocoding.find_coordinates_by_text(@search_term)
|
50
|
+
|
51
|
+
@address.should be_kind_of(Hash)
|
52
|
+
|
53
|
+
@address[:results].should be_kind_of(Array)
|
54
|
+
|
55
|
+
end
|
56
|
+
|
57
|
+
it "should return an error hash when trying to geocode an impossible search term" do
|
58
|
+
|
59
|
+
@wrong_address = @geocoding.find_coordinates_by_text(@wrong_search_term)
|
60
|
+
|
61
|
+
@wrong_address.should be_kind_of(Hash)
|
62
|
+
|
63
|
+
@wrong_address[:ERROR].should be_instance_of(String)
|
64
|
+
end
|
41
65
|
|
42
66
|
end
|
data/spec/spec_helper.rb
CHANGED
metadata
CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
|
|
5
5
|
segments:
|
6
6
|
- 0
|
7
7
|
- 0
|
8
|
-
-
|
9
|
-
version: 0.0.
|
8
|
+
- 2
|
9
|
+
version: 0.0.2
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- "Christian B\xC3\xA4uerlein"
|
@@ -14,7 +14,7 @@ autorequire:
|
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
16
|
|
17
|
-
date: 2010-05-
|
17
|
+
date: 2010-05-23 00:00:00 +02:00
|
18
18
|
default_executable:
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|
@@ -59,14 +59,14 @@ dependencies:
|
|
59
59
|
version: 2.6.0
|
60
60
|
type: :development
|
61
61
|
version_requirements: *id003
|
62
|
-
description:
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
*Note*: This is *not* an official client of MapTP or NAVTEQ, but a private project. :)
|
62
|
+
description: "This gem provides access to the MapTP web services.\n\n\
|
63
|
+
In order to use them, you need your MapTP credentials aka your Map24 id.\n\n\
|
64
|
+
For more information head over to http://www.nn4d.com\n\n\
|
65
|
+
You should consider that this client solely works with WGS\xC2\xB484 coordinates in the Decimal Degrees format.\n\
|
66
|
+
Usually MapTP services work with the Decimal Minutes format, but because Decimal Degrees are much more\n\
|
67
|
+
established we use it for this lib. To work with MapTP the parameters as well as the responses are\n\
|
68
|
+
converted internally.\n\n\
|
69
|
+
*Note*: This is *not* an official client of MapTP or NAVTEQ, but a private project. :)"
|
70
70
|
email:
|
71
71
|
- christian@ffwdme.com
|
72
72
|
executables: []
|
@@ -77,7 +77,6 @@ extra_rdoc_files:
|
|
77
77
|
- History.txt
|
78
78
|
- Manifest.txt
|
79
79
|
- PostInstall.txt
|
80
|
-
- nbproject/private/rake-d.txt
|
81
80
|
files:
|
82
81
|
- History.txt
|
83
82
|
- Manifest.txt
|
@@ -85,12 +84,10 @@ files:
|
|
85
84
|
- README.rdoc
|
86
85
|
- Rakefile
|
87
86
|
- lib/maptp-service.rb
|
87
|
+
- lib/maptp-service/parser/geocoding_result.rb
|
88
|
+
- lib/maptp-service/geocoding.rb
|
88
89
|
- lib/maptp-service/parser/route.rb
|
89
90
|
- lib/maptp-service/routing.rb
|
90
|
-
- nbproject/private/private.properties
|
91
|
-
- nbproject/private/rake-d.txt
|
92
|
-
- nbproject/project.properties
|
93
|
-
- nbproject/project.xml
|
94
91
|
- script/console
|
95
92
|
- script/destroy
|
96
93
|
- script/generate
|
@@ -1,48 +0,0 @@
|
|
1
|
-
announce=Announce your release.
|
2
|
-
audit=Run ZenTest against the package.
|
3
|
-
check_extra_deps=Install missing dependencies.
|
4
|
-
check_manifest=Verify the manifest.
|
5
|
-
check_version=
|
6
|
-
clean=Clean up all the extras.
|
7
|
-
clobber=
|
8
|
-
clobber_docs=Remove rdoc products
|
9
|
-
clobber_package=Remove package products
|
10
|
-
clobber_rcov=
|
11
|
-
config_hoe=Create a fresh ~/.hoerc file.
|
12
|
-
debug_email=Generate email announcement file.
|
13
|
-
debug_gem=Show information about the gem.
|
14
|
-
default=Run the default task(s).
|
15
|
-
deps\:email=Print a contact list for gems dependent on this gem
|
16
|
-
deps\:fetch=Fetch all the dependent gems of this gem into tarballs
|
17
|
-
deps\:list=List all the dependent gems of this gem
|
18
|
-
doc=
|
19
|
-
doc/index.html=
|
20
|
-
docs=Build the RDOC HTML Files
|
21
|
-
gem=Build the gem file maptp-service-0.0.1.gem
|
22
|
-
gemspec=Generate a maptp-service.gemspec file
|
23
|
-
generate_key=Generate a key for signing your gems.
|
24
|
-
install_gem=Install the package as a gem.
|
25
|
-
install_gem_no_doc=Install the package as a gem, without generating documentation(ri/rdoc)
|
26
|
-
manifest=Recreate Manifest.txt to include ALL files to be deployed
|
27
|
-
newb=Install deps, generate docs, run tests/specs.
|
28
|
-
package=Build all the packages
|
29
|
-
pkg=
|
30
|
-
pkg/maptp-service-0.0.1=
|
31
|
-
pkg/maptp-service-0.0.1.gem=
|
32
|
-
pkg/maptp-service-0.0.1.tgz=
|
33
|
-
post_blog=Post announcement to blog.
|
34
|
-
post_news=Post announcement to rubyforge.
|
35
|
-
postrelease=
|
36
|
-
prerelease=
|
37
|
-
publish_docs=Publish RDoc to wherever you want.
|
38
|
-
publish_on_announce=
|
39
|
-
redocs=Force a rebuild of the RDOC files
|
40
|
-
release=Package and upload the release.
|
41
|
-
release_sanity=Sanity checks for release
|
42
|
-
release_to=
|
43
|
-
release_to_gemcutter=Push gem to gemcutter.
|
44
|
-
release_to_rubyforge=Release to rubyforge.
|
45
|
-
repackage=Force a rebuild of the package files
|
46
|
-
ridocs=Generate ri locally for testing.
|
47
|
-
ruby_env=
|
48
|
-
spec=Run all specifications
|
data/nbproject/project.xml
DELETED
@@ -1,15 +0,0 @@
|
|
1
|
-
<?xml version="1.0" encoding="UTF-8"?>
|
2
|
-
<project xmlns="http://www.netbeans.org/ns/project/1">
|
3
|
-
<type>org.netbeans.modules.ruby.rubyproject</type>
|
4
|
-
<configuration>
|
5
|
-
<data xmlns="http://www.netbeans.org/ns/ruby-project/1">
|
6
|
-
<name>maptp-service</name>
|
7
|
-
<source-roots>
|
8
|
-
<root id="src.dir"/>
|
9
|
-
</source-roots>
|
10
|
-
<test-roots>
|
11
|
-
<root id="test.src.dir"/>
|
12
|
-
</test-roots>
|
13
|
-
</data>
|
14
|
-
</configuration>
|
15
|
-
</project>
|