Skip to content

[Feature] clone + dbscan - #239

Draft
NithyaNN3 wants to merge 7 commits into
dartclub:mainfrom
deanpapas:feature-dbscan
Draft

[Feature] clone + dbscan#239
NithyaNN3 wants to merge 7 commits into
dartclub:mainfrom
deanpapas:feature-dbscan

Conversation

@NithyaNN3

Copy link
Copy Markdown
Contributor

No description provided.

Comment thread lib/src/dbscan.dart

@lukas-h lukas-h left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • remove unnecessary code
  • run tests
  • then merge

Comment thread lib/src/clone.dart

// Deep clone any GeoJSON object: FeatureCollection, Feature, Geometry, and Properties.

dynamic clone(dynamic geojson) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tighten types --- e.g. use GeoJSONObject here ...

Comment thread lib/src/clone.dart
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');
}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we might be able to get rid of most of it - we already should have .clone(...) as an overridable function in GeoJSONObject

Comment thread lib/src/clone.dart
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);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we should be able to get rid of all of these clone helpers. this is something js specific that we don't need

@hamishdgx hamishdgx self-assigned this May 12, 2026
@hamishdgx
hamishdgx marked this pull request as draft May 19, 2026 05:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants