spatial_features 3.5.1 → 3.6.0
Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c477982103b4f48e410ff562a0bf0e16ec24e4cd3b42584aa5015cde9d380264
|
4
|
+
data.tar.gz: 9982438597418015427e05f060ac060f2a3ab803930c06d8a5e9a7578153129f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4aa2e8cdb7a59b4bf113489055c0d3018b3fb01ce5e18d6a03ec77d865e177b84231715abab3c410d5aba837db2fc0f0ebf2dd6ab70d5892567aaeda7b6e4e0a
|
7
|
+
data.tar.gz: 9a823d0703242fff4b790428b531a52d6017aa28e5922d87052066ff72e8056fa841825566e4feb0d48f10b238ca0be5570393ffe126108cf8c057efac3dbfba
|
data/README.md
CHANGED
@@ -106,7 +106,8 @@ Person.new(:features => [Feature.new(:geog => 'some binary PostGIS Geography str
|
|
106
106
|
### Import
|
107
107
|
|
108
108
|
You can specify multiple import sources for geometry. Each key is a method that returns the data for the Importer, and
|
109
|
-
each value is the Importer to use to parse the data.
|
109
|
+
each value is the Importer to use to parse the data. Options can be passed in place of the Importer name, but must still
|
110
|
+
include a `name` key with the name of the importer. See each Importer for more details.
|
110
111
|
```ruby
|
111
112
|
def ImageImporter
|
112
113
|
def self.call(feature, image_paths)
|
@@ -117,8 +118,11 @@ def ImageImporter
|
|
117
118
|
end
|
118
119
|
|
119
120
|
class Location < ActiveRecord::Base
|
120
|
-
has_spatial_features :
|
121
|
-
:
|
121
|
+
has_spatial_features :image_handlers => ['ImageImporter'],
|
122
|
+
:import => {
|
123
|
+
:remote_kml_url => { :name => 'KMLFile', :feature_name => lambda {|source_feature| source_feature.metadata['shapeID'] },
|
124
|
+
:file => 'File', :geojson => 'ESRIGeoJSON' }
|
125
|
+
}
|
122
126
|
|
123
127
|
def remote_kml_url
|
124
128
|
"www.test.com/kml/#{id}.kml"
|
@@ -88,10 +88,20 @@ module SpatialFeatures
|
|
88
88
|
private
|
89
89
|
|
90
90
|
def spatial_feature_imports(import_options, make_valid, tmpdir)
|
91
|
-
import_options.flat_map do |data_method,
|
91
|
+
import_options.flat_map do |data_method, configuration|
|
92
|
+
case configuration
|
93
|
+
when Hash
|
94
|
+
importer_name = configuration.fetch(:name)
|
95
|
+
options = configuration.except(:name)
|
96
|
+
else
|
97
|
+
importer_name = configuration
|
98
|
+
options = {}
|
99
|
+
end
|
100
|
+
|
92
101
|
Array.wrap(send(data_method)).flat_map do |data|
|
93
102
|
next unless data.present?
|
94
|
-
|
103
|
+
|
104
|
+
spatial_importer_from_name(importer_name).create_all(data, **options, :make_valid => make_valid, :tmpdir => tmpdir)
|
95
105
|
end
|
96
106
|
end.compact
|
97
107
|
end
|
@@ -6,12 +6,13 @@ module SpatialFeatures
|
|
6
6
|
attr_reader :errors
|
7
7
|
attr_accessor :source_identifier # An identifier for the source of the features. Used to differentiate groups of features on the spatial model.
|
8
8
|
|
9
|
-
def initialize(data, make_valid: false, tmpdir: nil, source_identifier: nil)
|
9
|
+
def initialize(data, make_valid: false, tmpdir: nil, source_identifier: nil, feature_name: ->(record) { record.name })
|
10
10
|
@make_valid = make_valid
|
11
11
|
@data = data
|
12
12
|
@errors = []
|
13
13
|
@tmpdir = tmpdir
|
14
14
|
@source_identifier = source_identifier
|
15
|
+
@feature_name = feature_name
|
15
16
|
end
|
16
17
|
|
17
18
|
def features
|
@@ -51,13 +52,12 @@ module SpatialFeatures
|
|
51
52
|
def build_feature(record)
|
52
53
|
importable_image_paths = record.importable_image_paths if record.respond_to?(:importable_image_paths)
|
53
54
|
Feature.new do |feature|
|
54
|
-
feature.name = record.name
|
55
55
|
feature.metadata = record.metadata
|
56
|
-
feature.feature_type = record.feature_type
|
57
56
|
feature.geog = record.geog
|
58
57
|
feature.importable_image_paths = importable_image_paths
|
59
58
|
feature.make_valid = @make_valid
|
60
59
|
feature.source_identifier = source_identifier
|
60
|
+
feature.name = @feature_name.is_a?(Proc) ? @feature_name.call(record) : @feature_name
|
61
61
|
end
|
62
62
|
end
|
63
63
|
end
|
@@ -22,9 +22,9 @@ module SpatialFeatures
|
|
22
22
|
def each_record(&block)
|
23
23
|
{'Polygon' => 'POLYGON', 'LineString' => 'LINE', 'Point' => 'POINT'}.each do |kml_type, sql_type|
|
24
24
|
kml_document.css(kml_type).each do |feature|
|
25
|
-
if placemark = feature.ancestors('Placemark').first
|
26
|
-
name = placemark.css('name').text
|
25
|
+
if (placemark = feature.ancestors('Placemark').first)
|
27
26
|
metadata = extract_metadata(placemark)
|
27
|
+
name = placemark.css('name').text
|
28
28
|
else
|
29
29
|
metadata = {}
|
30
30
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: spatial_features
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.
|
4
|
+
version: 3.6.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ryan Wallace
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2024-
|
12
|
+
date: 2024-02-06 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rails
|