feat: make Mol explorer map-first
This commit is contained in:
@@ -92,7 +92,7 @@ class VectorFeatureService:
|
||||
normalized_bbox = VectorFeatureService._normalize_selection_bbox(bbox)
|
||||
safe_limit = max(1, min(int(limit), 1000))
|
||||
|
||||
rows = (
|
||||
query = (
|
||||
db.query(VectorFeature)
|
||||
.filter(VectorFeature.dataset_id == dataset_id)
|
||||
.filter(
|
||||
@@ -107,17 +107,25 @@ class VectorFeatureService:
|
||||
),
|
||||
)
|
||||
)
|
||||
.order_by(VectorFeature.created_at.asc())
|
||||
)
|
||||
if hasattr(query, "count"):
|
||||
total_feature_count = int(query.count())
|
||||
else: # Lightweight unit-test sessions do not always implement Query.count().
|
||||
total_feature_count = len(query.all())
|
||||
|
||||
rows = (
|
||||
query.order_by(VectorFeature.created_at.asc())
|
||||
.limit(safe_limit + 1)
|
||||
.all()
|
||||
)
|
||||
truncated = len(rows) > safe_limit
|
||||
truncated = total_feature_count > safe_limit
|
||||
selected_rows = rows[:safe_limit]
|
||||
features = [VectorFeatureService._row_to_geojson_feature(row) for row in selected_rows]
|
||||
|
||||
return {
|
||||
"selection_bbox": normalized_bbox,
|
||||
"feature_count": len(features),
|
||||
"total_feature_count": total_feature_count,
|
||||
"limit": safe_limit,
|
||||
"truncated": truncated,
|
||||
"geojson": {
|
||||
|
||||
Reference in New Issue
Block a user