Skip to content

Commit

Permalink
removed geo and fixed rock7
Browse files Browse the repository at this point in the history
  • Loading branch information
EricAndrechek committed Apr 10, 2024
1 parent 79ff39e commit fa6e162
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 20 deletions.
2 changes: 1 addition & 1 deletion tracking-dashboard/backend/api/data.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ def api_rock7_upload():

# if callsign is not in data, add as serial
if 'callsign' not in decoded_data:
decoded_data['callsign'] = data['serial'][:6]
decoded_data['callsign'] = str(data['serial'])[:6]
# if ssid is not in data, add as 0
if 'ssid' not in decoded_data:
decoded_data['ssid'] = 0
Expand Down
11 changes: 2 additions & 9 deletions tracking-dashboard/backend/sql/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,10 @@
def add_datum(name, data):
# add to redis queue for adding to mqtt by worker
if isinstance(data, Position):
latitude = None
longitude = None
# convert geometry to lat/lon
if data.geo is not None:
print("geo: ", data.geo)
latitude = data.geo.split(" ")[0].split("(")[1]
longitude = data.geo.split(" ")[1].split(")")[0]
mqtt_data = {
"name": name,
"lat": latitude,
"lon": longitude,
"lat": data.latitude,
"lon": data.longitude,
"alt": data.altitude,
"cse": data.course,
"spd": data.speed,
Expand Down
6 changes: 3 additions & 3 deletions tracking-dashboard/backend/sql/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@

from sqlalchemy import Column, Integer, String, Text, DateTime, Float, ForeignKey, Boolean
from sqlalchemy.dialects.postgresql import JSONB
from geoalchemy2 import Geometry
from sqlalchemy.sql import func

from datetime import datetime
Expand Down Expand Up @@ -68,7 +67,8 @@ class Position(Base):
symbol = Column(String(2), nullable=False)
speed = Column(Float, nullable=True)
course = Column(Float, nullable=True)
geo = Column(Geometry('POINT'), nullable=True)
latitude = Column(Float, nullable=True)
longitude = Column(Float, nullable=True)
altitude = Column(Float, nullable=True)
comment = Column(String, nullable=True)
telemetry = Column(Integer, ForeignKey('telemetry.id'), nullable=True)
Expand All @@ -84,7 +84,7 @@ class Position(Base):
)

def __repr__(self):
return "<Position(id='%s', message='%s', callsign='%s', ssid='%s', symbol='%s', speed='%s', course='%s', geo='%s', altitude='%s', comment='%s', telemetry='%s')>" % (self.id, self.message, self.callsign, self.ssid, self.symbol, self.speed, self.course, self.geo, self.altitude, self.comment, self.telemetry)
return "<Position(id='%s', message='%s', callsign='%s', ssid='%s', symbol='%s', speed='%s', course='%s', latitude='%s', longitude='%s', altitude='%s', comment='%s', telemetry='%s')>" % (self.id, self.message, self.callsign, self.ssid, self.symbol, self.speed, self.course, self.latitude, self.longitude, self.altitude, self.comment, self.telemetry)

class Items(Base):
__tablename__ = 'items'
Expand Down
9 changes: 2 additions & 7 deletions tracking-dashboard/backend/utils/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -218,18 +218,13 @@ def save(self, save_timestamp=False):
if 'lat' in self.data and 'lon' in self.data:
print("position exists")

# build Geometry POINT object for lat/lon
# format: 'POINT(-33.9034 152.73457)'
geo_point = f"POINT({self.data['lat']} {self.data['lon']})" if "lat" in self.data and self.data["lat"] is not None and "lon" in self.data and self.data["lon"] is not None else None

print(geo_point)

# add to position table
position = Position(
callsign=self.data["callsign"],
ssid=self.data["ssid"],
symbol=self.data["symbol"],
geo=geo_point,
latitude=self.data["lat"],
longitude=self.data["lon"],
altitude=self.data["alt"],
course=self.data["course"],
speed=self.data["speed"],
Expand Down

0 comments on commit fa6e162

Please sign in to comment.