Skip to content

Commit

Permalink
Improve data generator (#20)
Browse files Browse the repository at this point in the history
  • Loading branch information
estebanzimanyi authored Sep 23, 2024
1 parent fa06165 commit dda5790
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 17 deletions.
28 changes: 14 additions & 14 deletions BerlinMOD/berlinmod_load.sql
Original file line number Diff line number Diff line change
Expand Up @@ -86,9 +86,9 @@ BEGIN
'DELIMITER '','' CSV HEADER', fullpath);

IF gist THEN
CREATE INDEX Points_Geom_gist_idx ON Points USING gist(Geom);
CREATE INDEX Points_Geom_gist_idx ON Points USING GIST(Geom);
ELSE
CREATE INDEX Points_Geom_spgist_idx ON Points USING spgist(Geom);
CREATE INDEX Points_Geom_spgist_idx ON Points USING SPGIST(Geom);
END IF;

/* There are NO duplicate points in Points
Expand Down Expand Up @@ -116,9 +116,9 @@ BEGIN
'FROM ''%sregions.csv'' DELIMITER '','' CSV HEADER', fullpath);

IF gist THEN
CREATE INDEX Regions_Geom_gist_idx ON Regions USING gist(Geom);
CREATE INDEX Regions_Geom_gist_idx ON Regions USING GIST(Geom);
ELSE
CREATE INDEX Regions_Geom_spgist_idx ON Regions USING spgist(Geom);
CREATE INDEX Regions_Geom_spgist_idx ON Regions USING SPGIST(Geom);
END IF;

CREATE VIEW Regions1 (RegionId, Geom) AS
Expand Down Expand Up @@ -146,10 +146,10 @@ BEGIN

IF gist THEN
CREATE INDEX Municipalities_MunicipalityGeo_gist_idx ON Municipalities
USING gist(MunicipalityGeo);
USING GIST(MunicipalityGeo);
ELSE
CREATE INDEX Municipalities_MunicipalityGeo_spgist_idx ON Municipalities
USING spgist(MunicipalityGeo);
USING SPGIST(MunicipalityGeo);
END IF;

--------------------------------------------------------------
Expand Down Expand Up @@ -181,10 +181,10 @@ BEGIN
'DELIMITER '','' CSV HEADER', fullpath);
IF gist THEN
CREATE INDEX RoadSegments_SegmentGeo_gist_idx ON RoadSegments
USING gist(SegmentGeo);
USING GIST(SegmentGeo);
ELSE
CREATE INDEX RoadSegments_SegmentGeo_spgist_idx ON RoadSegments
USING spgist(SegmentGeo);
USING SPGIST(SegmentGeo);
END IF;

--------------------------------------------------------------
Expand Down Expand Up @@ -215,7 +215,7 @@ BEGIN
EXECUTE format('COPY Licences(LicenceId, Licence, VehicleId) '
'FROM ''%slicences.csv'' DELIMITER '','' CSV HEADER', fullpath);

CREATE INDEX Licences_VehId_idx ON Licences USING btree(VehicleId);
CREATE INDEX Licences_VehicleId_idx ON Licences USING BTREE(VehicleId);

/* There are duplicate licences in Licences, e.g., in SF 0.005
SELECT COUNT(*)
Expand Down Expand Up @@ -272,14 +272,14 @@ BEGIN
UPDATE Trips
SET Trajectory = trajectory(Trip);

CREATE INDEX Trips_VehId_idx ON Trips USING btree(VehicleId);
CREATE INDEX Trips_VehicleId_idx ON Trips USING BTREE(VehicleId);

IF gist THEN
CREATE INDEX Trips_Trip_gist_idx ON Trips USING gist(Trip);
CREATE INDEX Trips_Trajectory_gist_idx ON Trips USING gist(Trajectory);
CREATE INDEX Trips_Trip_gist_idx ON Trips USING GIST(Trip);
CREATE INDEX Trips_Trajectory_gist_idx ON Trips USING GIST(Trajectory);
ELSE
CREATE INDEX Trips_Trip_spgist_idx ON Trips USING spgist(Trip);
CREATE INDEX Trips_Trajectory_spgist_idx ON Trips USING spgist(Trajectory);
CREATE INDEX Trips_Trip_spgist_idx ON Trips USING SPGIST(Trip);
CREATE INDEX Trips_Trajectory_spgist_idx ON Trips USING SPGIST(Trajectory);
END IF;

DROP VIEW IF EXISTS Trips1;
Expand Down
4 changes: 3 additions & 1 deletion BerlinMOD/deliveries_datagenerator.sql
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ functions are executed using the following tables
* Regions(RegionId int primary key, Geom geometry)
* Instants(InstantId int primary key, Instant timestamptz)
* Periods(PeriodId int primary key, Period tstzspan)
* Date(DateId serial primary key, Date date, WeekNo int, MonthNo int,
MonthName text, Quarter int, Year int)
In addition the following work tables are created
Expand Down Expand Up @@ -644,7 +646,7 @@ BEGIN
UPDATE Date SET
WeekNo = EXTRACT(week FROM Date),
MonthNo = EXTRACT(month FROM Date),
MonthName = TO_CHAR(Date, 'Month'),
MonthName = TRIM(TO_CHAR(Date, 'Month')),
Quarter = EXTRACT(quarter FROM Date),
Year = EXTRACT(year FROM Date);

Expand Down
4 changes: 2 additions & 2 deletions BerlinMOD/deliveries_load.sql
Original file line number Diff line number Diff line change
Expand Up @@ -177,8 +177,8 @@ BEGIN
DROP TABLE IF EXISTS Customers CASCADE;
CREATE TABLE Customers (
CustomerId integer PRIMARY KEY,
MunicipalityId integer REFERENCES Municipalities(MunicipalityId),
CustomerGeo geometry(Point, 3857) NOT NULL
CustomerGeo geometry(Point, 3857) NOT NULL,
MunicipalityId integer REFERENCES Municipalities(MunicipalityId)
);
EXECUTE format('COPY Customers(CustomerId, CustomerGeo, MunicipalityId) '
' FROM ''%scustomers.csv'' DELIMITER '','' CSV HEADER', fullpath);
Expand Down

0 comments on commit dda5790

Please sign in to comment.