-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
initial improvements #1
base: main
Are you sure you want to change the base?
Conversation
793b07d
to
3688138
Compare
Just a quick note, before I forget it: I think we should have validation in different modes:
|
@@ -1,7 +1,7 @@ | |||
# GeoTypes | |||
A lightweight library for GeoJSON data types available dart and flutter. | |||
A lightweight GeoJson library for dart and Flutter. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Dart
|
||
// "bbox": [-10.0, -10.0, 10.0, 10.0], | ||
List<ValidationHint> validateBoundingBox(dynamic bbox) { | ||
final hints = <ValidationHint>[]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
replace hints with direct returns
/// "prop1": 0.0 | ||
/// } | ||
/// }] | ||
/// } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
add ``` at the end
final hints = <ValidationHint>[]; | ||
|
||
if (json["type"] != "FeatureCollection") { | ||
hints.add(ValidationHint.geometryTypeInvalid); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should be ValidationHint.geoJsonObjectTypeInvalid
if (features == null || features is! List) { | ||
hints.add(ValidationHint.featureCollectionFeaturesMustBeAList); | ||
} else { | ||
if (features.isNotEmpty) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove if
} else if (!json.containsKey("type")) { | ||
hints.add(ValidationHint.geometryMustHaveType); | ||
} else { | ||
final validators = { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
use type <String,List Function(dynamic)>
} else if (!json.containsKey("type")) { | ||
hints.add(ValidationHint.geometryMustHaveType); | ||
} else { | ||
final validators = { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
use type!
hints.add(ValidationHint.geometryCollectionGeometriesShouldHaveItems); | ||
} | ||
for (final geometry in geometries) { | ||
hints.addAll(validateGeometry(geometry)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
here we need a geometryCollectionShouldNotBeNested
/// validatePosition([115, -35, 100]); | ||
/// ``` | ||
|
||
// ToDo: remove null and List check and use strong type here! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
implement todo
if (position.length < 2) { | ||
errors.add(ValidationHint.positionMustContainAtLeast2Elements); | ||
} else if (position.length > 3) { | ||
// SHOULD NOT extend positions beyond three elements |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove comment
ValidationHint.geometryCollectionGeometriesMustBeAList, | ||
ValidationHint.geometryMustBeAnObject, | ||
ValidationHint.geometryMustHaveType, | ||
ValidationHint.geometryTypeInvalid, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we need geometryTypeInvalid AND geoJsonTypeInvalid
|
||
final second = Feature(bbox: bbox).toJson(); | ||
final jsonString = JsonEncoder.withIndent(" ").convert(second); | ||
print(jsonString); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove print
expect(second.containsKey('bbox'), true); | ||
}); | ||
|
||
test('GeometryCollection', () { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove test
No description provided.