-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
51be370
commit af506fb
Showing
2 changed files
with
87 additions
and
0 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 |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import struct | ||
from io import BytesIO | ||
|
||
class Coordinates: | ||
def __init__(self, longitude, latitude): | ||
self.longitude = longitude | ||
self.latitude = latitude | ||
|
||
@classmethod | ||
def from_binary(cls, br): | ||
# Read longitude and latitude as doubles (8 bytes each) | ||
longitude, latitude = struct.unpack('dd', br.read(16)) | ||
return cls(longitude, latitude) | ||
|
||
def geometry_from_bytes(geo_bytes): | ||
# Initialize a stream to read binary data from the byte array | ||
with BytesIO(geo_bytes) as ms: | ||
# Read the first 4 bytes for the integer (len in C#) | ||
len_val = struct.unpack('i', ms.read(4))[0] | ||
coordinates_list = [] | ||
|
||
# Iterate and unpack each pair of doubles as coordinates | ||
for _ in range(len_val): | ||
coordinates = Coordinates.from_binary(ms) | ||
coordinates_list.append(coordinates) | ||
|
||
return coordinates_list |
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,60 @@ | ||
WITH issues AS ( | ||
--select the most recent version of each issue | ||
SELECT DISTINCT ON (divisionid, issueid) | ||
divisionid, | ||
issueid, | ||
timestamputc, | ||
issuetype, | ||
description, | ||
priority, | ||
proposedstarttimestamputc, | ||
proposedendtimestamputc, | ||
earlyendtimestamputc, | ||
status, | ||
timeoption | ||
FROM public.issuedata | ||
WHERE divisionid = 8048 --rodars new | ||
ORDER BY divisionid, issueid, timestamputc DESC | ||
) | ||
|
||
SELECT | ||
issues.divisionid, | ||
issues.issueid, | ||
issues.timestamputc, | ||
issues.issuetype, | ||
issues.description, | ||
issues.priority, | ||
issues.proposedstarttimestamputc, | ||
issues.proposedendtimestamputc, | ||
issues.earlyendtimestamputc, | ||
issues.status, | ||
issues.timeoption, | ||
issuelocationnew.locationindex, | ||
issuelocationnew.mainroadname, | ||
issuelocationnew.fromroadname, | ||
issuelocationnew.toroadname, | ||
issuelocationnew.direction, | ||
issuelocationnew.lanesaffected, | ||
issuelocationnew.geometry, | ||
issuelocationnew.streetnumber, | ||
issuelocationnew.locationtype, | ||
issuelocationnew.groupid, | ||
issuelocationnew.groupdescription, | ||
issueconfig.sourceid, | ||
issueconfig.starttimestamputc, | ||
issueconfig.endtimestamputc, | ||
issueconfig.kmpost, | ||
issueconfig.managementurl, | ||
issueconfig.cancellationstatus, | ||
issueconfig.closeissueonplannedendtime, | ||
issueconfig.plannedstartadvancenoticeseconds, | ||
issueconfig.plannedendadvancenoticeseconds, | ||
issueconfig.locationdescriptionoverwrite, | ||
issueconfig.startissueonplannedstarttime, | ||
issueconfig.startstatus, | ||
issueconfig.updateremindernoticeseconds | ||
FROM public.issues | ||
LEFT JOIN public.issuelocationnew USING (divisionid, issueid, timestamputc) | ||
LEFT JOIN public.issueconfig USING (divisionid, issueid) | ||
ORDER BY issueid DESC | ||
LIMIT 1000 |