[Feature] clone + dbscan - #239
Draft
NithyaNN3 wants to merge 7 commits into
Draft
Conversation
hamishdgx
reviewed
Mar 23, 2026
lukas-h
requested changes
May 12, 2026
lukas-h
left a comment
Member
There was a problem hiding this comment.
- remove unnecessary code
- run tests
- then merge
|
|
||
| // Deep clone any GeoJSON object: FeatureCollection, Feature, Geometry, and Properties. | ||
|
|
||
| dynamic clone(dynamic geojson) { |
Member
There was a problem hiding this comment.
tighten types --- e.g. use GeoJSONObject here ...
Comment on lines
+9
to
+24
| switch (geojson['type']) { | ||
| case 'Feature': | ||
| return cloneFeature(geojson); | ||
| case 'FeatureCollection': | ||
| return cloneFeatureCollection(geojson); | ||
| case 'Point': | ||
| case 'LineString': | ||
| case 'Polygon': | ||
| case 'MultiPoint': | ||
| case 'MultiLineString': | ||
| case 'MultiPolygon': | ||
| case 'GeometryCollection': | ||
| return cloneGeometry(geojson); | ||
| default: | ||
| throw ArgumentError('unknown GeoJSON type'); | ||
| } |
Member
There was a problem hiding this comment.
we might be able to get rid of most of it - we already should have .clone(...) as an overridable function in GeoJSONObject
Comment on lines
+27
to
+52
| Map<String, dynamic> cloneFeature(Map<String, dynamic> geojson) { | ||
| final cloned = <String, dynamic>{'type': 'Feature'}; | ||
|
|
||
| // Preserve foreign members | ||
| geojson.forEach((key, value) { | ||
| if (key != 'type' && key != 'properties' && key != 'geometry') { | ||
| cloned[key] = value; | ||
| } | ||
| }); | ||
|
|
||
| cloned['properties'] = cloneProperties(geojson['properties']); | ||
| cloned['geometry'] = geojson['geometry'] == null | ||
| ? null | ||
| : cloneGeometry(geojson['geometry']); | ||
|
|
||
| return cloned; | ||
| } | ||
|
|
||
| dynamic cloneProperties(dynamic properties) { | ||
| if (properties == null) return {}; | ||
|
|
||
| final cloned = <String, dynamic>{}; | ||
|
|
||
| (properties as Map<String, dynamic>).forEach((key, value) { | ||
| if (value is Map) { | ||
| cloned[key] = cloneProperties(value); |
Member
There was a problem hiding this comment.
we should be able to get rid of all of these clone helpers. this is something js specific that we don't need
hamishdgx
marked this pull request as draft
May 19, 2026 05:49
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.