Skip to content
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

Draft
wants to merge 13 commits into
base: main
Choose a base branch
from
Draft

initial improvements #1

wants to merge 13 commits into from

Conversation

jsiedentop
Copy link
Contributor

No description provided.

@jsiedentop jsiedentop self-assigned this Feb 28, 2024
@jsiedentop jsiedentop linked an issue Mar 8, 2024 that may be closed by this pull request
@lukas-h
Copy link
Member

lukas-h commented Mar 11, 2024

Just a quick note, before I forget it: I think we should have validation in different modes:

  • via asserts (only debug mode, not in production)
  • via throws (everywhere)
  • etc.
    Library user should decide if they want strict mode, etc.

@@ -1,7 +1,7 @@
# GeoTypes
A lightweight library for GeoJSON data types available dart and flutter.
A lightweight GeoJson library for dart and Flutter.
Copy link
Contributor Author

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>[];
Copy link
Contributor Author

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
/// }
/// }]
/// }
Copy link
Contributor Author

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);
Copy link
Contributor Author

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) {
Copy link
Contributor Author

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 = {
Copy link
Contributor Author

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 = {
Copy link
Contributor Author

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));
Copy link
Contributor Author

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!
Copy link
Contributor Author

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
Copy link
Contributor Author

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,
Copy link
Contributor Author

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);
Copy link
Contributor Author

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', () {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

remove test

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants