Skip to content

Commit

Permalink
Altitude re-enabled
Browse files Browse the repository at this point in the history
Temporary countermeasure against #256
  • Loading branch information
landswellsong committed Aug 21, 2017
1 parent afb4ff0 commit 3ba7b0e
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 4 deletions.
4 changes: 4 additions & 0 deletions backend/promis/backend_api/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
from django.db import models
from django.db.models.fields import ( DateTimeField, IntegerField, CharField,
DateField, FloatField, TextField )
from django.contrib.postgres.fields import ArrayField
from django.db.models.fields.related import ForeignKey
from jsonfield import JSONField
from django.contrib.gis.db.models import LineStringField
Expand Down Expand Up @@ -92,6 +93,9 @@ class Session(models.Model):
# but ensures distances and intersections are caclulated correctly
# TODO: srid should eventually be 4979 see #222
geo_line = LineStringField(dim = 3, srid = 4326, geography=True)

# TODO: 4D coordinates, see #256
altitude = ArrayField(FloatField())
space_project = ForeignKey('Space_project', null = True)

class Meta:
Expand Down
4 changes: 3 additions & 1 deletion backend/promis/backend_api/serializer.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,9 @@ def get_geo_line(self, obj):
#return obj.geo_line.wkb.hex()

# TODO: study whether pre-building the list or JSON would speed up things
return parsers.wkb(obj.geo_line.wkb) # <- Generator
# TODO: ugly hack before #256
# geo_line.wkb calls a generator implicitly
return ( (*geo[:2], alt) for alt, geo in zip(obj.altitude, parsers.wkb(obj.geo_line.wkb)) )

def get_timelapse(self, obj):
# TODO: change to time_start in model for consistency
Expand Down
8 changes: 6 additions & 2 deletions backend/promis/classes/potential.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,10 @@ def fetch(self, daydir):
ez_time_end = time_end

# Generator for the orbit
line_gen = ( (y.lon, y.lat, t) for t, y, _ in orbit.generate_orbit(orbit_path, time_start, time_end) )
# TODO: rewrite as generator if possible at all
path = [ (y.lon, y.lat, y.alt, t) for t, y, _ in orbit.generate_orbit(orbit_path, time_start, time_end) ]
line_gen = [ (x, y, t) for x, y, _, t in path ]
alt_gen = [ alt for _, _, alt, _ in path ]
# Converting time to python objects for convenience
# This is the point where onboard time gets converted to the UTC
time_start = unix_time.maketime(time_start)
Expand All @@ -143,7 +146,8 @@ def fetch(self, daydir):
# Creating a session object
# TODO: make it more readable
# TODO: srid should be 4979 see #222
ez_sess_obj = model.Session.objects.create(time_begin = time_start, time_end = time_end, geo_line = LineString(*line_gen, srid = 4326), space_project = self.project_obj )
ez_sess_obj = model.Session.objects.create(time_begin = time_start, time_end = time_end, altitude = alt_gen,
geo_line = LineString(*line_gen, srid = 4326), space_project = self.project_obj )

# TODO: record data_id in the object
# TODO: somehow generalise this process maybe
Expand Down
2 changes: 1 addition & 1 deletion frontend/app/components/CesiumMap.js
Original file line number Diff line number Diff line change
Expand Up @@ -486,7 +486,7 @@ export default class CesiumContainer extends Component {

/* data is [lat, lon, hgt] */
data.forEach(function(point) { // TODO temporary disabling altitude because it stores time temporarily
cartesians.push(Cartesian3.fromDegrees(point[1], point[0], /*point[2] ? point[2] :*/ 250000));
cartesians.push(Cartesian3.fromDegrees(point[1], point[0], point[2] ? point[2] *1000 : 250000));
});

return this.viewer.entities.add({
Expand Down

0 comments on commit 3ba7b0e

Please sign in to comment.