citysdk 0.1.2.4 → 0.1.2.5
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.
- checksums.yaml +4 -4
- data/lib/citysdk/api.rb +2 -8
- data/lib/citysdk/file_reader.rb +15 -8
- data/lib/citysdk/importer.rb +10 -5
- data/lib/citysdk.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f0fd4a218a56d9c50a060909e9d27308f7262b72
|
4
|
+
data.tar.gz: dbcead5631b8cd87d3844d319e51843ec3b859c6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3c9c553e8e707ca27f07c12d57700c219471b60a5c1efeab62148f2912ab196cfd98739294143432cc6f63097d22beadeb5d10b0e5266e0ff91a56c8562327d1
|
7
|
+
data.tar.gz: 1ffd5cd48feaabef893c68b558e6e6ace96a3a2de6cbed74d9ef8ab4a6c76c3424c466b207ab7760dffb7e0006c374d5da436939a8b516ba815ba2a1c1472dec
|
data/lib/citysdk/api.rb
CHANGED
@@ -69,17 +69,11 @@ module CitySDK
|
|
69
69
|
@port = $2
|
70
70
|
@host = $1
|
71
71
|
else
|
72
|
-
@port =
|
72
|
+
@port = 80
|
73
73
|
end
|
74
74
|
end
|
75
75
|
|
76
|
-
@
|
77
|
-
|
78
|
-
if host =~ /^https/
|
79
|
-
@connection = Faraday.new :url => "https://#{@host}:#{@port}", :ssl => {:verify => false}
|
80
|
-
else
|
81
|
-
@connection = Faraday.new :url => "http://#{@host}:#{@port}"
|
82
|
-
end
|
76
|
+
@connection = Faraday.new :url => "http://#{@host}:#{@port}"
|
83
77
|
@connection.headers = {
|
84
78
|
:user_agent => 'CitySDK_API GEM ' + CitySDK::VERSION,
|
85
79
|
:content_type => 'application/json'
|
data/lib/citysdk/file_reader.rb
CHANGED
@@ -43,11 +43,11 @@ module CitySDK
|
|
43
43
|
|
44
44
|
|
45
45
|
@params[:rowcount] = @content.length
|
46
|
-
getFields
|
47
|
-
guessName
|
48
|
-
guessSRID
|
49
|
-
findUniqueField
|
50
|
-
getAddress
|
46
|
+
getFields unless @params[:fields]
|
47
|
+
guessName unless @params[:name]
|
48
|
+
guessSRID unless @params[:srid]
|
49
|
+
findUniqueField unless @params[:unique_id]
|
50
|
+
getAddress unless @params[:hasaddress]
|
51
51
|
@params[:hasgeometry] = 'unknown' if @params[:hasgeometry].nil?
|
52
52
|
end
|
53
53
|
|
@@ -320,6 +320,7 @@ module CitySDK
|
|
320
320
|
end
|
321
321
|
|
322
322
|
def readShape(path)
|
323
|
+
|
323
324
|
@content = []
|
324
325
|
@file = path
|
325
326
|
|
@@ -337,7 +338,9 @@ module CitySDK
|
|
337
338
|
h[:properties] = {}
|
338
339
|
att_data = shape.data #a Hash
|
339
340
|
shp.fields.each do |field|
|
340
|
-
|
341
|
+
s = att_data[field.name]
|
342
|
+
s = s.force_encoding('ISO8859-1') if s.class == String
|
343
|
+
h[:properties][field.name.to_sym] = s
|
341
344
|
end
|
342
345
|
@content << h
|
343
346
|
end
|
@@ -353,7 +356,10 @@ module CitySDK
|
|
353
356
|
def readZip(path)
|
354
357
|
begin
|
355
358
|
Dir.mktmpdir("cdkfi_#{File.basename(path).gsub(/\A/,'')}") do |dir|
|
356
|
-
raise "Error unzipping #{path}." if not system "unzip '#{path}' -d '#{dir}' > /dev/null 2>&1"
|
359
|
+
raise CitySDK::Exception.new("Error unzipping #{path}.", {:originalfile => path}, __FILE__,__LINE__) if not system "unzip '#{path}' -d '#{dir}' > /dev/null 2>&1"
|
360
|
+
if File.directory?(dir + '/' + File.basename(path).chomp(File.extname(path)))
|
361
|
+
dir = dir + '/' + File.basename(path).chomp(File.extname(path) )
|
362
|
+
end
|
357
363
|
Dir.foreach(dir) do |f|
|
358
364
|
next if f =~ /^\./
|
359
365
|
case File.extname(f)
|
@@ -370,8 +376,9 @@ module CitySDK
|
|
370
376
|
end
|
371
377
|
end
|
372
378
|
rescue Exception => e
|
373
|
-
raise CitySDK::Exception(e.message, {:originalfile => path}, __FILE__,__LINE__)
|
379
|
+
raise CitySDK::Exception.new(e.message, {:originalfile => path}, __FILE__,__LINE__)
|
374
380
|
end
|
381
|
+
raise CitySDK::Exception.new("Could not proecess file #{path}", {:originalfile => path}, __FILE__,__LINE__)
|
375
382
|
end
|
376
383
|
|
377
384
|
def write(path=nil)
|
data/lib/citysdk/importer.rb
CHANGED
@@ -101,8 +101,12 @@ module CitySDK
|
|
101
101
|
# puts "data: \n#{data}"
|
102
102
|
data
|
103
103
|
end
|
104
|
+
|
105
|
+
|
106
|
+
|
107
|
+
|
104
108
|
|
105
|
-
def doImport(dryrun=false)
|
109
|
+
def doImport(dryrun=false, &block)
|
106
110
|
result = {
|
107
111
|
:updated => 0,
|
108
112
|
:created => 0,
|
@@ -112,9 +116,7 @@ module CitySDK
|
|
112
116
|
failed = nil
|
113
117
|
|
114
118
|
if @params[:hasaddress] == 'certain'
|
115
|
-
failed = addToAddress(dryrun)
|
116
|
-
# elsif @params[:hasaddress] == 'maybe'
|
117
|
-
# failed = addToAddress(dryrun)
|
119
|
+
failed = addToAddress(dryrun, &block)
|
118
120
|
end
|
119
121
|
|
120
122
|
# TODO: add possibility to add node to postal code
|
@@ -123,6 +125,7 @@ module CitySDK
|
|
123
125
|
result[:updated] += @filereader.content.length
|
124
126
|
return result
|
125
127
|
end
|
128
|
+
|
126
129
|
if failed
|
127
130
|
result[:updated] += (@filereader.content.length - failed.length)
|
128
131
|
end
|
@@ -235,7 +238,9 @@ module CitySDK
|
|
235
238
|
end
|
236
239
|
if qres[:status]=='success' and qres[:results] and qres[:results][0]
|
237
240
|
url = '/' + qres[:results][0][:cdk_id] + '/' + @params[:layername]
|
238
|
-
|
241
|
+
data = filterFields(row)
|
242
|
+
yield({addto: qres[:results][0][:cdk_id], data: data}) if block_given?
|
243
|
+
n = @api.put(url,{'data'=>data}) if not dryrun
|
239
244
|
else
|
240
245
|
failed << rec
|
241
246
|
end
|
data/lib/citysdk.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: citysdk
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.2.
|
4
|
+
version: 0.1.2.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tom Demeyer
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-04-
|
11
|
+
date: 2014-04-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: dbf
|