Fix: Clean up map_iframe_single.html, remove debug overlay, ensure clean map rendering.
This commit is contained in:
@@ -175,6 +175,83 @@ class Like(db.Model):
|
||||
def __repr__(self):
|
||||
return f'<Like {self.user_id}-{self.post_id}>'
|
||||
|
||||
class MapRoute(db.Model):
|
||||
__tablename__ = 'map_routes'
|
||||
|
||||
id = db.Column(db.Integer, primary_key=True)
|
||||
|
||||
# Route Data (stored as JSON for efficient loading)
|
||||
coordinates = db.Column(db.Text, nullable=False) # JSON array of [lat, lng] points
|
||||
simplified_coordinates = db.Column(db.Text) # Simplified version for map overview
|
||||
|
||||
# Route Bounds
|
||||
start_latitude = db.Column(db.Float, nullable=False)
|
||||
start_longitude = db.Column(db.Float, nullable=False)
|
||||
end_latitude = db.Column(db.Float, nullable=False)
|
||||
end_longitude = db.Column(db.Float, nullable=False)
|
||||
|
||||
# Bounding Box for map fitting
|
||||
bounds_north = db.Column(db.Float, nullable=False)
|
||||
bounds_south = db.Column(db.Float, nullable=False)
|
||||
bounds_east = db.Column(db.Float, nullable=False)
|
||||
bounds_west = db.Column(db.Float, nullable=False)
|
||||
|
||||
# Route Statistics (copied from GPX processing)
|
||||
total_distance = db.Column(db.Float, default=0.0) # in kilometers
|
||||
elevation_gain = db.Column(db.Float, default=0.0) # in meters
|
||||
max_elevation = db.Column(db.Float, default=0.0) # in meters
|
||||
min_elevation = db.Column(db.Float, default=0.0) # in meters
|
||||
total_points = db.Column(db.Integer, default=0) # original number of points
|
||||
simplified_points = db.Column(db.Integer, default=0) # simplified points count
|
||||
|
||||
# Metadata
|
||||
created_at = db.Column(db.DateTime, default=datetime.utcnow)
|
||||
updated_at = db.Column(db.DateTime, default=datetime.utcnow, onupdate=datetime.utcnow)
|
||||
|
||||
# Foreign Keys
|
||||
post_id = db.Column(db.Integer, db.ForeignKey('posts.id'), nullable=False, unique=True)
|
||||
gpx_file_id = db.Column(db.Integer, db.ForeignKey('gpx_files.id'), nullable=False)
|
||||
|
||||
# Relationships
|
||||
post = db.relationship('Post', backref=db.backref('map_route', uselist=False))
|
||||
gpx_file = db.relationship('GPXFile', backref='map_route')
|
||||
|
||||
def get_coordinates_json(self):
|
||||
"""Get coordinates as parsed JSON"""
|
||||
import json
|
||||
return json.loads(self.coordinates) if self.coordinates else []
|
||||
|
||||
def get_simplified_coordinates_json(self):
|
||||
"""Get simplified coordinates as parsed JSON"""
|
||||
import json
|
||||
return json.loads(self.simplified_coordinates) if self.simplified_coordinates else []
|
||||
|
||||
def get_bounds(self):
|
||||
"""Get bounding box as dict"""
|
||||
return {
|
||||
'north': self.bounds_north,
|
||||
'south': self.bounds_south,
|
||||
'east': self.bounds_east,
|
||||
'west': self.bounds_west
|
||||
}
|
||||
|
||||
def get_start_point(self):
|
||||
"""Get start point as dict"""
|
||||
return {
|
||||
'latitude': self.start_latitude,
|
||||
'longitude': self.start_longitude
|
||||
}
|
||||
|
||||
def get_end_point(self):
|
||||
"""Get end point as dict"""
|
||||
return {
|
||||
'latitude': self.end_latitude,
|
||||
'longitude': self.end_longitude
|
||||
}
|
||||
|
||||
def __repr__(self):
|
||||
return f'<MapRoute for Post {self.post_id}>'
|
||||
|
||||
class PageView(db.Model):
|
||||
__tablename__ = 'page_views'
|
||||
|
||||
|
||||
Reference in New Issue
Block a user