activerecord-mysql2rgeo-adapter 2.0.3 → 5.2.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/lib/active_record/connection_adapters/mysql2rgeo/arel_tosql.rb +3 -1
- data/lib/active_record/connection_adapters/mysql2rgeo/column_methods.rb +28 -25
- data/lib/active_record/connection_adapters/mysql2rgeo/create_connection.rb +4 -2
- data/lib/active_record/connection_adapters/mysql2rgeo/schema_statements.rb +48 -19
- data/lib/active_record/connection_adapters/mysql2rgeo/spatial_column.rb +3 -4
- data/lib/active_record/connection_adapters/mysql2rgeo/spatial_table_definition.rb +0 -5
- data/lib/active_record/connection_adapters/mysql2rgeo/version.rb +4 -2
- data/lib/active_record/connection_adapters/mysql2rgeo_adapter.rb +17 -50
- data/lib/active_record/type/spatial.rb +42 -56
- data/lib/activerecord-mysql2rgeo-adapter.rb +2 -0
- metadata +7 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 8be8c0bd91551b3593b6be777f8a05243fc136f79e01234678550a09233bb607
|
4
|
+
data.tar.gz: ce6f2c3b063af63d66a8779f007c8367639c8d3f8dea4225680477f0a48ff5eb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0aa088c4492c15cdab24145b41c3ba37dea76e2b298a03332445698f0b278f2be7c5ed506249d8b4bfe5f214c2d1bd8566eec9e9dabcbcf6a093d3928125e198
|
7
|
+
data.tar.gz: 4cdb993e6a3893cfaa57ad38d21618cbce0ea303d05914586ccf488e2907bab1c2a4aaa2be2bbee0eb9819850173c1d437592fca8c73c92f806f26e387062c83
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module Arel # :nodoc:
|
2
4
|
module Visitors # :nodoc:
|
3
5
|
# Different super-class under JRuby JDBC adapter.
|
@@ -5,7 +7,7 @@ module Arel # :nodoc:
|
|
5
7
|
::ArJdbc::MySQL::BindSubstitution
|
6
8
|
else
|
7
9
|
MySQL
|
8
|
-
|
10
|
+
end
|
9
11
|
|
10
12
|
class Mysql2Rgeo < MySQLSuperclass # :nodoc:
|
11
13
|
include RGeo::ActiveRecord::SpatialToSql
|
@@ -1,51 +1,54 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module ActiveRecord
|
2
4
|
module ConnectionAdapters
|
3
5
|
module Mysql2Rgeo
|
4
6
|
module ColumnMethods
|
5
7
|
def spatial(name, options = {})
|
6
|
-
raise "You must set a type. For example: 't.spatial :
|
7
|
-
column(name, options[:limit][:type], options)
|
8
|
-
end
|
8
|
+
raise "You must set a type. For example: 't.spatial type: :point'" unless options[:type]
|
9
9
|
|
10
|
-
|
11
|
-
multi ? multi_geometry(*args, **options) : args.each { |name| column(name, :geometry, options) }
|
10
|
+
column(name, options[:type], options)
|
12
11
|
end
|
13
12
|
|
14
|
-
def
|
15
|
-
|
13
|
+
def geometry(name, options = {})
|
14
|
+
column(name, :geometry, options)
|
16
15
|
end
|
17
16
|
|
18
|
-
def
|
19
|
-
|
17
|
+
def geometry_collection(name, options = {})
|
18
|
+
column(name, :geometrycollection, options)
|
20
19
|
end
|
20
|
+
alias geometrycollection geometry_collection
|
21
21
|
|
22
|
-
def
|
23
|
-
|
22
|
+
def line_string(name, options = {})
|
23
|
+
column(name, :linestring, options)
|
24
24
|
end
|
25
|
+
alias linestring line_string
|
25
26
|
|
26
|
-
def
|
27
|
-
|
27
|
+
def multi_line_string(name, options = {})
|
28
|
+
column(name, :multilinestring, options)
|
28
29
|
end
|
30
|
+
alias multilinestring multi_line_string
|
29
31
|
|
30
|
-
def
|
31
|
-
|
32
|
+
def multi_point(name, options = {})
|
33
|
+
column(name, :multipoint, options)
|
32
34
|
end
|
35
|
+
alias multipoint multi_point
|
33
36
|
|
34
|
-
def
|
35
|
-
|
37
|
+
def multi_polygon(name, options = {})
|
38
|
+
column(name, :multipolygon, options)
|
36
39
|
end
|
40
|
+
alias multipolygon multi_polygon
|
37
41
|
|
38
|
-
def
|
39
|
-
|
42
|
+
def point(name, options = {})
|
43
|
+
column(name, :point, options)
|
40
44
|
end
|
41
45
|
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
alias multi_polygon multipolygon
|
46
|
+
def polygon(name, options = {})
|
47
|
+
column(name, :polygon, options)
|
48
|
+
end
|
46
49
|
end
|
47
|
-
|
48
|
-
MySQL::Table.send(:include, ColumnMethods)
|
49
50
|
end
|
51
|
+
|
52
|
+
MySQL::Table.include Mysql2Rgeo::ColumnMethods
|
50
53
|
end
|
51
54
|
end
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
if RUBY_ENGINE == "jruby"
|
2
4
|
require "active_record/connection_adapters/jdbcmysql_adapter"
|
3
5
|
else
|
@@ -13,7 +15,7 @@ module ActiveRecord # :nodoc:
|
|
13
15
|
mysql2_connection(config)
|
14
16
|
end
|
15
17
|
|
16
|
-
|
18
|
+
alias_method :jdbcmysql2rgeo_connection, :mysql2rgeo_connection
|
17
19
|
|
18
20
|
else
|
19
21
|
|
@@ -29,7 +31,7 @@ module ActiveRecord # :nodoc:
|
|
29
31
|
|
30
32
|
if Mysql2::Client.const_defined? :FOUND_ROWS
|
31
33
|
if config[:flags].is_a? Array
|
32
|
-
config[:flags].push "FOUND_ROWS"
|
34
|
+
config[:flags].push "FOUND_ROWS"
|
33
35
|
else
|
34
36
|
config[:flags] |= Mysql2::Client::FOUND_ROWS
|
35
37
|
end
|
@@ -1,16 +1,21 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module ActiveRecord
|
2
4
|
module ConnectionAdapters
|
3
5
|
module Mysql2Rgeo
|
4
6
|
module SchemaStatements
|
5
7
|
# override
|
6
|
-
def
|
7
|
-
|
8
|
+
def indexes(table_name) #:nodoc:
|
9
|
+
indexes = super
|
10
|
+
# HACK(aleks, 06/15/18): MySQL 5 does not support prefix lengths for spatial indexes
|
11
|
+
# https://dev.mysql.com/doc/refman/5.6/en/create-index.html
|
12
|
+
indexes.select { |idx| idx.type == :spatial }.each { |idx| idx.is_a?(Struct) ? idx.lengths = {} : idx.instance_variable_set(:@lengths, {}) }
|
13
|
+
indexes
|
8
14
|
end
|
9
15
|
|
10
16
|
def type_to_sql(type, limit: nil, precision: nil, scale: nil, unsigned: nil, **) # :nodoc:
|
11
17
|
if (info = RGeo::ActiveRecord.geometric_type_from_name(type.to_s.delete("_")))
|
12
18
|
type = limit[:type] || type if limit.is_a?(::Hash)
|
13
|
-
type = :geometry if type.eql? :spatial
|
14
19
|
type = type.to_s.delete("_").upcase
|
15
20
|
end
|
16
21
|
super
|
@@ -19,32 +24,28 @@ module ActiveRecord
|
|
19
24
|
# override
|
20
25
|
def native_database_types
|
21
26
|
# Add spatial types
|
27
|
+
# Reference: https://dev.mysql.com/doc/refman/5.6/en/spatial-type-overview.html
|
22
28
|
super.merge(
|
23
|
-
geometry:
|
24
|
-
|
25
|
-
linestring:
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
29
|
+
geometry: { name: "geometry" },
|
30
|
+
geometrycollection: { name: "geometrycollection" },
|
31
|
+
linestring: { name: "linestring" },
|
32
|
+
multi_line_string: { name: "multilinestring" },
|
33
|
+
multi_point: { name: "multipoint" },
|
34
|
+
multi_polygon: { name: "multipolygon" },
|
35
|
+
spatial: { name: "geometry" },
|
36
|
+
point: { name: "point" },
|
37
|
+
polygon: { name: "polygon" }
|
32
38
|
)
|
33
39
|
end
|
34
40
|
|
35
|
-
|
36
|
-
def create_table_definition(*args)
|
37
|
-
Mysql2Rgeo::TableDefinition.new(*args)
|
38
|
-
end
|
39
|
-
|
40
|
-
def initialize_type_map(m)
|
41
|
+
def initialize_type_map(m = type_map)
|
41
42
|
super
|
42
43
|
%w(
|
43
44
|
geometry
|
45
|
+
geometrycollection
|
44
46
|
point
|
45
47
|
linestring
|
46
48
|
polygon
|
47
|
-
geometrycollection
|
48
49
|
multipoint
|
49
50
|
multilinestring
|
50
51
|
multipolygon
|
@@ -52,6 +53,34 @@ module ActiveRecord
|
|
52
53
|
m.register_type(geo_type, Type::Spatial.new(geo_type))
|
53
54
|
end
|
54
55
|
end
|
56
|
+
|
57
|
+
private
|
58
|
+
|
59
|
+
# override
|
60
|
+
def create_table_definition(*args)
|
61
|
+
Mysql2Rgeo::TableDefinition.new(*args)
|
62
|
+
end
|
63
|
+
|
64
|
+
# override
|
65
|
+
def new_column_from_field(table_name, field)
|
66
|
+
type_metadata = fetch_type_metadata(field[:Type], field[:Extra])
|
67
|
+
if type_metadata.type == :datetime && /\ACURRENT_TIMESTAMP(?:\([0-6]?\))?\z/i.match?(field[:Default])
|
68
|
+
default, default_function = nil, field[:Default]
|
69
|
+
else
|
70
|
+
default, default_function = field[:Default], nil
|
71
|
+
end
|
72
|
+
|
73
|
+
SpatialColumn.new(
|
74
|
+
field[:Field],
|
75
|
+
default,
|
76
|
+
type_metadata,
|
77
|
+
field[:Null] == "YES",
|
78
|
+
table_name,
|
79
|
+
default_function,
|
80
|
+
field[:Collation],
|
81
|
+
comment: field[:Comment].presence
|
82
|
+
)
|
83
|
+
end
|
55
84
|
end
|
56
85
|
end
|
57
86
|
end
|
@@ -11,8 +11,7 @@ module ActiveRecord # :nodoc:
|
|
11
11
|
# @geometric_type = geo_type_from_sql_type(sql_type)
|
12
12
|
build_from_sql_type(sql_type_metadata.sql_type)
|
13
13
|
end
|
14
|
-
super(name, default, sql_type_metadata, null, table_name, default_function, collation)
|
15
|
-
@comment = comment
|
14
|
+
super(name, default, sql_type_metadata, null, table_name, default_function, collation, comment: comment)
|
16
15
|
if spatial?
|
17
16
|
if @srid
|
18
17
|
@limit = { type: @geometric_type.type_name.underscore }
|
@@ -35,9 +34,9 @@ module ActiveRecord # :nodoc:
|
|
35
34
|
false
|
36
35
|
end
|
37
36
|
|
37
|
+
alias :geographic? :geographic
|
38
38
|
alias :has_z? :has_z
|
39
39
|
alias :has_m? :has_m
|
40
|
-
alias :geographic? :geographic
|
41
40
|
|
42
41
|
def limit
|
43
42
|
if spatial?
|
@@ -66,7 +65,7 @@ module ActiveRecord # :nodoc:
|
|
66
65
|
end
|
67
66
|
|
68
67
|
def build_from_sql_type(sql_type)
|
69
|
-
geo_type, @srid
|
68
|
+
geo_type, @srid = Type::Spatial.parse_sql_type(sql_type)
|
70
69
|
set_geometric_type_from_name(geo_type)
|
71
70
|
end
|
72
71
|
end
|
@@ -12,9 +12,6 @@ module ActiveRecord # :nodoc:
|
|
12
12
|
end
|
13
13
|
|
14
14
|
geo_type = ColumnDefinitionUtils.geo_type(options[:type] || type || info[:type])
|
15
|
-
base_type = info[:type] || :geometry
|
16
|
-
|
17
|
-
# puts name.dup << " - " << type.to_s << " - " << options.to_s << " :: " << geo_type.to_s << " - " << base_type.to_s
|
18
15
|
|
19
16
|
options[:spatial_type] = geo_type
|
20
17
|
column = super(name, geo_type.downcase.to_sym, options)
|
@@ -26,8 +23,6 @@ module ActiveRecord # :nodoc:
|
|
26
23
|
end
|
27
24
|
end
|
28
25
|
|
29
|
-
SpatialIndexDefinition = Struct.new(*IndexDefinition.members, :spatial)
|
30
|
-
|
31
26
|
module ColumnDefinitionUtils
|
32
27
|
class << self
|
33
28
|
def geo_type(type = "GEOMETRY")
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
# The activerecord-mysql2rgeo-adapter gem installs the *mysql2rgeo*
|
2
4
|
# connection adapter into ActiveRecord.
|
3
5
|
|
@@ -22,6 +24,7 @@ require "active_record/connection_adapters/mysql2rgeo/spatial_expressions"
|
|
22
24
|
require "active_record/connection_adapters/mysql2rgeo/arel_tosql"
|
23
25
|
require "active_record/type/spatial"
|
24
26
|
require "active_record/connection_adapters/mysql2rgeo/create_connection"
|
27
|
+
require "active_record/tasks/database_tasks"
|
25
28
|
|
26
29
|
# :startdoc:
|
27
30
|
|
@@ -32,16 +35,16 @@ module ActiveRecord
|
|
32
35
|
|
33
36
|
SPATIAL_COLUMN_OPTIONS =
|
34
37
|
{
|
35
|
-
geometry:
|
36
|
-
geometrycollection:
|
37
|
-
linestring:
|
38
|
-
multilinestring:
|
39
|
-
multipoint:
|
40
|
-
multipolygon:
|
41
|
-
spatial:
|
42
|
-
point:
|
43
|
-
polygon:
|
44
|
-
}
|
38
|
+
geometry: {},
|
39
|
+
geometrycollection: {},
|
40
|
+
linestring: {},
|
41
|
+
multilinestring: {},
|
42
|
+
multipoint: {},
|
43
|
+
multipolygon: {},
|
44
|
+
spatial: { type: "geometry" },
|
45
|
+
point: {},
|
46
|
+
polygon: {}
|
47
|
+
}
|
45
48
|
|
46
49
|
# http://postgis.17.x6.nabble.com/Default-SRID-td5001115.html
|
47
50
|
DEFAULT_SRID = 0
|
@@ -50,11 +53,10 @@ module ActiveRecord
|
|
50
53
|
super
|
51
54
|
|
52
55
|
@visitor = Arel::Visitors::Mysql2Rgeo.new(self)
|
53
|
-
@visitor.extend(DetermineIfPreparableVisitor) if self.class.type_cast_config_to_boolean(config.fetch(:prepared_statements) { true })
|
54
56
|
end
|
55
57
|
|
56
58
|
def adapter_name
|
57
|
-
"Mysql2Rgeo"
|
59
|
+
"Mysql2Rgeo"
|
58
60
|
end
|
59
61
|
|
60
62
|
def self.spatial_column_options(key)
|
@@ -69,45 +71,10 @@ module ActiveRecord
|
|
69
71
|
!mariadb? && version >= "5.7.6"
|
70
72
|
end
|
71
73
|
|
72
|
-
# Returns an array of indexes for the given table.
|
73
|
-
def indexes(table_name, name = nil) #:nodoc:
|
74
|
-
if name
|
75
|
-
ActiveSupport::Deprecation.warn(<<-MSG.squish)
|
76
|
-
Passing name to #indexes is deprecated without replacement.
|
77
|
-
MSG
|
78
|
-
end
|
79
|
-
|
80
|
-
indexes = []
|
81
|
-
current_index = nil
|
82
|
-
execute_and_free("SHOW KEYS FROM #{quote_table_name(table_name)}", "SCHEMA") do |result|
|
83
|
-
each_hash(result) do |row|
|
84
|
-
if current_index != row[:Key_name]
|
85
|
-
next if row[:Key_name] == "PRIMARY" # skip the primary key
|
86
|
-
current_index = row[:Key_name]
|
87
|
-
|
88
|
-
mysql_index_type = row[:Index_type].downcase.to_sym
|
89
|
-
index_type = INDEX_TYPES.include?(mysql_index_type) ? mysql_index_type : nil
|
90
|
-
index_using = INDEX_USINGS.include?(mysql_index_type) ? mysql_index_type : nil
|
91
|
-
options = [row[:Table], row[:Key_name], row[:Non_unique].to_i == 0, [], {}, nil, nil, index_type, index_using, row[:Index_comment].presence]
|
92
|
-
indexes << if mysql_index_type == :spatial
|
93
|
-
options.push(true)
|
94
|
-
Mysql2Rgeo::SpatialIndexDefinition.new(*options)
|
95
|
-
else
|
96
|
-
IndexDefinition.new(row[:Table], row[:Key_name], row[:Non_unique].to_i == 0, [], {}, nil, nil, index_type, index_using, row[:Index_comment].presence)
|
97
|
-
end
|
98
|
-
end
|
99
|
-
|
100
|
-
indexes.last.columns << row[:Column_name]
|
101
|
-
indexes.last.lengths.merge!(row[:Column_name] => row[:Sub_part].to_i) if row[:Sub_part] && mysql_index_type != :spatial
|
102
|
-
end
|
103
|
-
end
|
104
|
-
|
105
|
-
indexes
|
106
|
-
end
|
107
|
-
|
108
74
|
def quote(value)
|
109
|
-
|
110
|
-
|
75
|
+
dbval = value.try(:value_for_database) || value
|
76
|
+
if RGeo::Feature::Geometry.check_type(dbval)
|
77
|
+
"ST_GeomFromWKB(0x#{RGeo::WKRep::WKBGenerator.new(hex_format: true, little_endian: true).generate(dbval)},#{dbval.srid})"
|
111
78
|
else
|
112
79
|
super
|
113
80
|
end
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module ActiveRecord
|
2
4
|
module Type
|
3
5
|
class Spatial < Value # :nodoc:
|
@@ -14,66 +16,61 @@ module ActiveRecord
|
|
14
16
|
|
15
17
|
# sql_type: geometry, geometry(Point), geometry(Point,4326), ...
|
16
18
|
#
|
17
|
-
# returns [geo_type, srid
|
19
|
+
# returns [geo_type, srid]
|
18
20
|
# geo_type: geography, geometry, point, line_string, polygon, ...
|
19
21
|
# srid: 1234
|
20
|
-
# has_z: false
|
21
|
-
# has_m: false
|
22
22
|
def self.parse_sql_type(sql_type)
|
23
|
-
geo_type, srid
|
23
|
+
geo_type, srid = nil, 0, false, false
|
24
24
|
|
25
25
|
if sql_type =~ /(geography|geometry)\((.*)\)$/i
|
26
|
+
# geometry(Point)
|
26
27
|
# geometry(Point,4326)
|
27
28
|
params = Regexp.last_match(2).split(",")
|
28
|
-
if params.
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
end
|
34
|
-
if params.last =~ /(\d+)/
|
35
|
-
srid = Regexp.last_match(1).to_i
|
36
|
-
end
|
37
|
-
else
|
38
|
-
# geometry(Point)
|
39
|
-
geo_type = params[0]
|
29
|
+
if params.first =~ /([a-z]+[^zm])(z?)(m?)/i
|
30
|
+
geo_type = Regexp.last_match(1)
|
31
|
+
end
|
32
|
+
if params.last =~ /(\d+)/
|
33
|
+
srid = Regexp.last_match(1).to_i
|
40
34
|
end
|
41
35
|
else
|
42
36
|
# geometry
|
37
|
+
# otherType(a,b)
|
43
38
|
geo_type = sql_type
|
44
39
|
end
|
45
|
-
[geo_type, srid
|
40
|
+
[geo_type, srid]
|
46
41
|
end
|
47
42
|
|
48
|
-
def
|
49
|
-
|
43
|
+
def spatial_factory
|
44
|
+
@spatial_factory ||=
|
45
|
+
RGeo::ActiveRecord::SpatialFactoryStore.instance.factory(
|
46
|
+
geo_type: @geo_type,
|
47
|
+
sql_type: @sql_type,
|
48
|
+
srid: @srid
|
49
|
+
)
|
50
50
|
end
|
51
51
|
|
52
|
-
def
|
53
|
-
:geometry
|
52
|
+
def klass
|
53
|
+
type == :geometry ? RGeo::Feature::Geometry : super
|
54
54
|
end
|
55
55
|
|
56
56
|
def spatial?
|
57
57
|
true
|
58
58
|
end
|
59
59
|
|
60
|
-
def
|
61
|
-
|
62
|
-
RGeo::ActiveRecord::SpatialFactoryStore.instance.factory(
|
63
|
-
geo_type: @geo_type,
|
64
|
-
sql_type: @sql_type,
|
65
|
-
srid: @srid
|
66
|
-
)
|
60
|
+
def type
|
61
|
+
:geometry
|
67
62
|
end
|
68
63
|
|
69
64
|
# support setting an RGeo object or a WKT string
|
70
65
|
def serialize(value)
|
71
66
|
return if value.nil?
|
67
|
+
|
72
68
|
geo_value = cast_value(value)
|
73
69
|
|
74
70
|
# TODO - only valid types should be allowed
|
75
71
|
# e.g. linestring is not valid for point column
|
76
72
|
raise "maybe should raise" unless RGeo::Feature::Geometry.check_type(geo_value)
|
73
|
+
|
77
74
|
geo_value
|
78
75
|
end
|
79
76
|
|
@@ -81,35 +78,24 @@ module ActiveRecord
|
|
81
78
|
|
82
79
|
def cast_value(value)
|
83
80
|
return if value.nil?
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
srid = [srid].pack("V").unpack("N").first if value[9, 1] == "1"
|
100
|
-
begin
|
101
|
-
RGeo::WKRep::WKBParser.new(spatial_factory, support_ewkb: true, default_srid: srid).parse(value[8..-1])
|
102
|
-
rescue
|
103
|
-
nil
|
104
|
-
end
|
105
|
-
else
|
106
|
-
begin
|
107
|
-
RGeo::WKRep::WKTParser.new(spatial_factory, support_ewkt: true, default_srid: @srid).parse(value)
|
108
|
-
rescue
|
109
|
-
nil
|
110
|
-
end
|
111
|
-
end
|
81
|
+
|
82
|
+
::String === value ? parse_wkt(value) : value
|
83
|
+
end
|
84
|
+
|
85
|
+
def parse_wkt(string)
|
86
|
+
marker = string[4, 1]
|
87
|
+
if marker == "\x00" || marker == "\x01"
|
88
|
+
srid = string[0, 4].unpack(marker == "\x01" ? "V" : "N").first
|
89
|
+
RGeo::WKRep::WKBParser.new(spatial_factory, support_ewkb: true, default_srid: srid).parse(string[4..-1])
|
90
|
+
elsif string[0, 10] =~ /[0-9a-fA-F]{8}0[01]/
|
91
|
+
srid = string[0, 8].to_i(16)
|
92
|
+
srid = [srid].pack("V").unpack("N").first if string[9, 1] == "1"
|
93
|
+
RGeo::WKRep::WKBParser.new(spatial_factory, support_ewkb: true, default_srid: srid).parse(string[8..-1])
|
94
|
+
else
|
95
|
+
RGeo::WKRep::WKTParser.new(spatial_factory, support_ewkt: true, default_srid: @srid).parse(string)
|
112
96
|
end
|
97
|
+
rescue RGeo::Error::ParseError, RGeo::Error::InvalidGeometry
|
98
|
+
nil
|
113
99
|
end
|
114
100
|
end
|
115
101
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: activerecord-mysql2rgeo-adapter
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 5.2.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Yongdae Hwang
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-04-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activerecord
|
@@ -30,28 +30,28 @@ dependencies:
|
|
30
30
|
requirements:
|
31
31
|
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: '
|
33
|
+
version: '6.0'
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
38
|
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: '
|
40
|
+
version: '6.0'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: rake
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
45
|
- - "~>"
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version: '
|
47
|
+
version: '13.0'
|
48
48
|
type: :development
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
52
|
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version: '
|
54
|
+
version: '13.0'
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: minitest
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
@@ -134,7 +134,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
134
134
|
version: '0'
|
135
135
|
requirements: []
|
136
136
|
rubyforge_project:
|
137
|
-
rubygems_version: 2.6
|
137
|
+
rubygems_version: 2.7.6
|
138
138
|
signing_key:
|
139
139
|
specification_version: 4
|
140
140
|
summary: ActiveRecord adapter for MySQL, based on RGeo.
|