-
-
Notifications
You must be signed in to change notification settings - Fork 64
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Upgrate Active Record dependency to 4.2. Drop rgeo 0.4 appraisal.
- Loading branch information
1 parent
a6ff36e
commit e10e441
Showing
9 changed files
with
76 additions
and
120 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,5 @@ | ||
appraise 'rgeo-0.4.0' do | ||
gem 'rgeo', '0.4.0' | ||
end | ||
|
||
appraise 'rgeo-0.6.0' do | ||
appraise 'current' do | ||
gem 'activerecord', '4.2.9' | ||
gem 'mysql2', '0.3.21' | ||
gem 'rgeo', '0.6.0' | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
module ActiveRecord | ||
module Type | ||
class Spatial < Value # :nodoc: | ||
def type | ||
:spatial | ||
end | ||
|
||
def spatial? | ||
type == :spatial | ||
end | ||
|
||
def klass | ||
type == :spatial ? ::RGeo::Feature::Geometry : super | ||
end | ||
|
||
def set_geo_params(factory_settings, table_name, geometric_type) | ||
@factory_settings = factory_settings | ||
@table_name = table_name | ||
@geometric_type = geometric_type | ||
end | ||
|
||
private | ||
|
||
def cast_value(value) | ||
case value | ||
when ::RGeo::Feature::Geometry | ||
factory = @factory_settings.get_column_factory(@table_name, @column, :srid => value.srid) | ||
::RGeo::Feature.cast(value, factory) rescue nil | ||
when ::String | ||
marker = value[4,1] | ||
if marker == "\x00" || marker == "\x01" | ||
factory = @factory_settings.get_column_factory(@table_name, @column, | ||
:srid => value[0,4].unpack(marker == "\x01" ? 'V' : 'N').first) | ||
::RGeo::WKRep::WKBParser.new(factory).parse(value[4..-1]) rescue nil | ||
elsif value[0,10] =~ /[0-9a-fA-F]{8}0[01]/ | ||
srid = value[0,8].to_i(16) | ||
if value[9,1] == '1' | ||
srid = [srid].pack('V').unpack('N').first | ||
end | ||
factory = @factory_settings.get_column_factory(@table_name, @column, :srid => srid) | ||
::RGeo::WKRep::WKBParser.new(factory).parse(value[8..-1]) rescue nil | ||
else | ||
factory = @factory_settings.get_column_factory(@table_name, @column) | ||
::RGeo::WKRep::WKTParser.new(factory, support_ewkt: true).parse(value) rescue nil | ||
end | ||
else | ||
nil | ||
end | ||
end | ||
|
||
end | ||
end | ||
end |