Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

A script/query adding vehicle_location_point to siri_arrivals #30

Closed
daphshez opened this issue May 29, 2017 · 5 comments
Closed

A script/query adding vehicle_location_point to siri_arrivals #30

daphshez opened this issue May 29, 2017 · 5 comments
Labels
Hackathon Preparation for the upcoming hackathon

Comments

@daphshez
Copy link
Collaborator

daphshez commented May 29, 2017

(note: this task is a little similar to #28, but is slightly simpler because indexing isn't required, and also has higher priority)

We are want to add geometry fields to our database in order to be able to run geoqueries using PostGIS.

The task is to create a script that:

  • Adds a geometry column named vehicle_location_point to the siri_arrivals table.
  • Updates the column to contain the data from vehicle_location_lat and vehicke_location_lon in the same table.

The script location should be under the /postgres folder in the source code.

Some additional pointers:

  • Use AddGeometryColumn rather than ALTER TABLE (see here why)
  • These are probably the correct parameters for add geometry column: srid = 4326 , type = "POINT" and dimension = 2
  • When inserting the data, vehicle_location_lon is the X value and vehicle_location_lat is the Y value

What you need to know to implement this task

  • SQL, some PostGIS. If you don't know any PostGIS, these should help:
  • You'll be touching the siri_arrivals table, but you don't really need to understand much about it except for the vehicle_location_lon & lat fields
  • You can probably create the query using the re:dash interface. If you need a local dev copy of the database, see Create a database dump for dev environment + docker? #32
  • Clone the repository and use pull requests to submit your code.
@LiorDL
Copy link
Collaborator

LiorDL commented Jun 9, 2017

Create column:
SELECT AddGeometryColumn ('siri_arrivals_filtered','vehicle_location_point',4326,'POINT',2);
Populate data:
update siri_arrivals_filtered set vehicle_location_point = ST_SetSRID(ST_MakePoint(cast(vehicle_location_lon as double precision), cast(vehicle_location_lat as double precision)),4326);

@LiorDL
Copy link
Collaborator

LiorDL commented Jun 10, 2017

The populate data query should also have the line:
where vehicle_location_lon !=''
(Otherwise the cast caused it to fail).
Only thing left to do is to add these queries to the loading scripts.

LiorDL added a commit that referenced this issue Jun 10, 2017
Query adding vehicle_location_point to siri_arrivals  - see issue #30
@MYank0
Copy link
Collaborator

MYank0 commented Jun 10, 2017

@daphshez can we close?

@LiorDL
Copy link
Collaborator

LiorDL commented Jun 12, 2017

Yes, I'm done with it =) @daphshez

@LiorDL
Copy link
Collaborator

LiorDL commented Jul 10, 2017

Note that has been changed so that there is no need to actually hold siri_arrivals_filtered column, we added it to the query that populates the data in Add route offset to siri_arrivals

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Hackathon Preparation for the upcoming hackathon
Projects
No open projects
Development

No branches or pull requests

3 participants