nofxx / georuby Goto Github PK
View Code? Open in Web Editor NEWThis is intended as a holder for geometric data. The data model roughly follows the OGC.
License: MIT License
This is intended as a holder for geometric data. The data model roughly follows the OGC.
License: MIT License
The code
` require 'geo_ruby/shp'
GeoRuby::Shp4r::ShpFile.open(shpfile) do |shp|
shp.each do |shape|
geom = shape.geometry #a GeoRuby SimpleFeature
att_data = shape.data #a Hash
shp.fields.each do |field|
puts att_data[field.name]
end
end
end`
Does seem to get the geometry nicely, but the att_data is completely empty (nil values all over)
if you have Shapefiles that have file extensions that are capitalized (i.e. shape_file.SHP instead of shape_file.shp), it throws a MalformedShpException despite the file(s) actually existing and being valid.
@file_root = file.gsub(/.shp$/i, '')
works as to pulling the correct root file because you are ignoring case.
However
unless File.exist?(@file_root + '.shp') && File.exist?(@file_root + '.dbf') && File.exist?(@file_root + '.shx')
fails to pick up the files because you are looking for files with the lower cased extensions.
Renaming all files from *.SHP to *.shp (etc) resolves the issue now, but would be nice if the code could figure this out.
The gem changed their interface. They removed the 6th parameter (encoding) for DBF::Column
See this commit in dbf project
infused/dbf@36065c0#diff-e0964a9a211a4a80381813c36ddf9141
Please change the Dbf::Field interface to use the changed API
Can we push the latest versions (tags) of the gem to Rubygems for things like the dbf 1.7 support?
I've done all the diagnosis I know how to do, but can't get any of the georuby classes to become available. What am I missing?
$ uname -a
Linux linux 3.13.0-20-generic #42-Ubuntu SMP Fri Mar 28 09:56:33 UTC 2014 x86_64 x86_64 x86_64 GNU/Linux
$ ruby -v
ruby 1.9.3p484 (2013-11-22 revision 43786) [x86_64-linux]
$ irb
irb(main):001:0> require 'georuby'
=> true
irb(main):002:0> p = Point.new
NameError: uninitialized constant Point
from (irb):2
from /usr/bin/irb:12:in `
Irked by this when using GeoRuby standalone to modify GeoJSON files.
/Users/parker/.rbenv/versions/2.1.1/lib/ruby/gems/2.1.0/gems/georuby-2.2.1/lib/geo_ruby/geojson.rb:40:in `as_json': undefined method `as_json' for #<Hash:0x007fb57a945958> (NoMethodError)
from /Users/parker/.rbenv/versions/2.1.1/lib/ruby/gems/2.1.0/gems/georuby-2.2.1/lib/geo_ruby/geojson.rb:44:in `to_json'
from /Users/parker/.rbenv/versions/2.1.1/lib/ruby/gems/2.1.0/gems/georuby-2.2.1/lib/geo_ruby/geojson.rb:70:in `to_json'
from /Users/parker/.rbenv/versions/2.1.1/lib/ruby/gems/2.1.0/gems/georuby-2.2.1/lib/geo_ruby/geojson.rb:70:in `to_json'
Do I need ActiveSupport? ActiveModel? If so, how can I avoid it?
I get the following error message when running the tests:
Failures:
1) GeoRuby::KmlParser should parse a GeoRuby::SimpleFeatures::LineString correctly
Failure/Error: g.as_kml.gsub(/\n/,'').should eql(LINEARRING)
SystemStackError:
stack level too deep
# ./lib/geo_ruby/simple_features/linear_ring.rb:18:in `orig_kml_representation'
# ./lib/geo_ruby/simple_features/linear_ring.rb:18:in `orig_kml_representation'
# ./lib/geo_ruby/simple_features/linear_ring.rb:18:in `kml_representation'
# ./lib/geo_ruby/simple_features/geometry.rb:139:in `as_kml'
# ./spec/geo_ruby/kml_spec.rb:40
first line in https://github.com/nofxx/georuby#geojson-support is rendered as
Basic GeoJSON support has been implemented per v1.0 of the {spec}[http://geojson.org/geojson-spec.html].
Hi,
It looks like the project has been stale for some time now. As a maintainer of RGeo, I understand that these kind of gems need great support and we'd love to have more of the community involved.
What do we say we explicitely redirect to rgeo and/or ffi-geos from this gem, and mark it as deprecated so community efforts are more likely to be focused?
As part of this, of course, any feature that is present here, missing in rgeo, and wanted by anyone could be asked for in rgeo.
Cheers,
Ulysse
h = "01010000207B000000CDCCCCCCCCCC28406666666666A64640"
f2 = GeometryFactory::new
ep = EWKBParser::new(f2)
e = [h].pack("H*")
ep.parse(e)
f2.geometry.x
=> 12.4
f1 = GeometryFactory::new
hp = HexEWKBParser::new(f1)
hp.parse(h)
f1.geometry.x
=> -3.495080594483092e-247
I haven't dug down deep in the code yet but no matter what epsilon I choose the simplify method returns a line_string object with only two points starting from about 2000 points.
Are there certain limitations on line_string#simplify?
This is the gpx file I'm testing:
https://gist.github.com/mklnz/0415d8bcf20c0cbf8456c97d18d929dc
Edit: Now I found out this is due to a conflict between Rail's ActiveSupport to_json and the json gem. Usage outside Rails environment works as intended. How to get around this?
I'm not sure if I'm using this functionality correctly or not, but I'm having trouble outputting a valid GeoJSON collection.
Example:
GeoJSONFeature.new(point1).to_json
Output:
{
"type":"Feature",
"geometry":{
"type":"Point",
"coordinates":[
121.4412656998513,
31.2108137285587
]
},
"properties":{
}
}
But when a GeoJSONFeature is inside an array, it skips over its own GeoJSONFeature#to_json
method (double checked with byebug) and is missing the "type": "Feature"
attribute.
Example:
[GeoJSONFeature.new(point1)].to_json
Output:
[
{
"geometry":{
"type":"Point",
"coordinates":[
121.4412656998513,
31.2108137285587
]
},
"properties":{
},
"id":null
}
]
Finally putting it together with a FeatureCollection:
features = [
GeoJSONFeature.new(start_point),
GeoJSONFeature.new(end_point)
]
GeoJSONFeatureCollection.new(features)
Output (not valid GeoJSON):
{
"type":"FeatureCollection",
"features":[
{
"geometry":{
"type":"Point",
"coordinates":[
121.4412656998513,
31.2108137285587
]
},
"properties":{
},
"id":null
},
{
"geometry":{
"type":"Point",
"coordinates":[
121.4569708797648,
31.219778491221284
]
},
"properties":{
},
"id":null
}
]
}
Hi,
I have georuby 2.5.2 loaded and DBF 2.0.7. When I require 'geo_ruby/shp', the constant that I see loaded if DBF (all caps) and there is no Field function available. Any ideas on what I can try to get access to the Dbf method to allow access to the custom functions?
Thanks,
Scott
Empty there...
Since you were so quick to help before, i hope you dont mind another issue :). ive looked at the GeoRuby code in the backtrace and i'm a bit lost. I also hope this is enough information to be useful.
`
Location.create({:user_id=>51,"latitude"=>"45.51163136959076", "longitude"=>"-122.61863350868225", "altitude"=>"37.0", "accuracy"=>"16.0", "heading"=>"0.0", "velocity"=>"0.0", "timestamp"=>"2010-10-12T21:53:07+0000", "batterylevel"=>"43"}).errors.full_messages
TypeError: can't convert String into Float
from /usr/local/ruby-1.9.2-p0/lib/ruby/gems/1.9.1/gems/GeoRuby-1.3.4/lib/geo_ruby/simple_features/point.rb:133:inpack' from /usr/local/ruby-1.9.2-p0/lib/ruby/gems/1.9.1/gems/GeoRuby-1.3.4/lib/geo_ruby/simple_features/point.rb:133:in
binary_representation'
from /usr/local/ruby-1.9.2-p0/lib/ruby/gems/1.9.1/gems/GeoRuby-1.3.4/lib/geo_ruby/simple_features/geometry.rb:66:inas_ewkb' from /usr/local/ruby-1.9.2-p0/lib/ruby/gems/1.9.1/gems/GeoRuby-1.3.4/lib/geo_ruby/simple_features/geometry.rb:76:in
as_hex_ewkb'
from /usr/local/ruby-1.9.2-p0/lib/ruby/gems/1.9.1/gems/postgis_adapter-0.7.8/lib/postgis_adapter.rb:114:inquote' from /usr/local/ruby-1.9.2-p0/lib/ruby/gems/1.9.1/gems/activerecord-2.3.8/lib/active_record/base.rb:3033:in
block in attributes_with_quotes'
`
My app connects to multiple databases via activerecord, some of which have postGIS and some do not.
When I use an AR class which connects to a db without postGIS,
I get a PG::Error (relation "geometry_columns" does not exist)
at spatial_adapter/postgresql.rb:216
in column_spatial_info.
I've been getting past this by including the following module in my AR objects, but would prefer a real fix.
module SupressSpatialCalculation # Since we dont have postGIS installed on this DB def column_spatial_info(column_name) {} end end
Would it make sense to handle this error within GeoRuby? (and maybe even disable the extra georuby features for that class when it's encountered)
When my model refreshes, I'm getting this error sometimes:
def read_point
i = @position
@position += 16
fail EWKBFormatError.new('Truncated data') if @ewkb.length < @position
@ewkb.unpack("@#{i}#{@double_mark}#{@double_mark}@*")
end
I'm getting this in my production and I also get it in my test cases intermittently. My testcases are threaded which is why I thought they were happening.
But... they are also happening on production which is not using threading and it is just normal Rails / Puma. It seems like there is some kind of race condition being hit when the database records are being refresh.
I'm using Sequel orm which might be the source, but I don't think that is causing it.
Can someone give me some insight why this might be happening intermittently?
Fails on require 'geo_ruby/shp'
with this error, TypeError: wrong argument type Module (expected Class)
Worked around it by specifying dbf 1.6.
When you publish on rubygems, please ensure code parity with github versions. Thanks!
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.