ateroconfigs / acts_as_line Goto Github PK
View Code? Open in Web Editor NEWPutsGIS. PostGIS, for Rails (featuring acts_as_line: treat start/end date columns as a single spatial object.)
Home Page: http://tempestattack.com
License: MIT License
PutsGIS. PostGIS, for Rails (featuring acts_as_line: treat start/end date columns as a single spatial object.)
Home Page: http://tempestattack.com
License: MIT License
being rewritten. see lib/act_as_line.rb for options. ActsAsLine ========== Need to add tests as a priority, and must clean things up. In order to maintain consistency with postgis methods, intersects is now simply intersects, the 'touching' alias has been removed. added: a.intersects?(b) a.covers?(b) a.covered_by?(b) Foo.within(b,:days,3,options={}) #also :secs, :hours Foo.covers(b,options={}) Foo.covered_by(b,options={}) covers: 'Geom A covers Geom B if no points of B lie in the exterior of A' Early days. Things are progressing (and probably breaking in places). Some big changes, and some very undry source.... acts_as_line.rb has been rewritten to include instance methods. I am basically adding functions as I need them. > b = Foo.find(:first) Length of line in seconds: > b.duration also > b.duration(:days) > b.duration(:weeks) Query against a part line, in this case the first half: > Foo.touching_segment(b,[0,0.5]) - where 0.5 is the midpoint of b's geom. A new line is created using the start/end points specified in the array. Find records that do not intersect the latter two thirds of the line (and have a bar_id of 5): > Foo.not_touching_segment(b,[0.3,1], :bar_id => 5) This needs to be able to support actual days/hours, rather than a proportion of a line -- which is not very robost if you are using it for bookings and such like. 'asunder' method is now not_touching. > b = Booking.find(:first) > Booking.not_touching(b) Foo.asunder is now an alias for the class method, not_in_intersects which uses joins to speed up queries against a large dataset. class Property < ActiveRecord::Base has_many :bookings acts_as_line end class Booking < ActiveRecord::Base belongs_to :property acts_as_line end class Bookable < ActiveRecord::Base acts_as_line end > week = Bookable.find(38) Find all *unbooked* properties for the booking period 'week' without selecting each property: > Property.asunder(Booking,week) SQL: SELECT (id) FROM properties WHERE properties.id NOT IN (SELECT DISTINCT on (properties.id) properties.id FROM bookings INNER JOIN properties ON properties.id=bookings.property_id WHERE (ST_Intersects(bookings.geom,(SELECT geom FROM bookables WHERE id = 38)) = true)) [SQL (0.000791) -- small dataset as yet, but seems reasonable] SELECT (id) FROM properties WHERE properties.id NOT IN (SELECT DISTINCT on (properties.id) properties.id FROM bookings INNER JOIN properties ON properties.id=bookings.property_id WHERE (ST_Intersects(bookings.geom,(SELECT geom FROM bookables WHERE id = 38)) = true)) Example ======= table must already have a start_date and end_date column of type date or datetime. script/generate datesgeom_migration table_name runs the following on target table: execute("ALTER TABLE table_name ADD COLUMN geom geometry;") execute("CREATE INDEX idx_table_name_dates_geom ON table_name USING GIST (geom);") object = Foo.find(:first) results = Foo.touching(object) | results = Foo.intersects(object,true) results = Foo.not_touching(object) | results = Foo.intersects(object,false) results = Foo.touching(object,{:id => 123}) results = Foo.touching(object,{:id => '>123'}) results = Foo.touching(object,{:id => '<>123'}) etc results = Foo.touching(object,{:id => 123, :title => 'bar'})
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.