Skip to content
This repository has been archived by the owner on May 27, 2024. It is now read-only.

Query by bounds #41

Open
wants to merge 18 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# Changelog

## 1.1.0

- Add bounding box search option
- Read files inside isolate
- Correctly dispose and cleanup objects

## 1.0.0

Migration to null safety
Expand Down
54 changes: 28 additions & 26 deletions lib/src/deserializers.dart
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import 'package:geopoint/geopoint.dart';

import 'geopoint/geopoint.dart';
import 'geopoint/geoserie.dart';
import 'models.dart';

/// Get a collection inside another collection
GeoJsonGeometryCollection getGeometryCollection(
{List<GeoJsonFeature<dynamic>?>? geometries,
GeoJsonFeature<dynamic>? feature,
String? nameProperty}) {
{final List<GeoJsonFeature<dynamic>?>? geometries,
final GeoJsonFeature<dynamic>? feature,
final String? nameProperty}) {
final name = _getName(feature: feature, nameProperty: nameProperty);
final collection =
GeoJsonGeometryCollection(geometries: geometries, name: name);
Expand All @@ -15,19 +15,19 @@ GeoJsonGeometryCollection getGeometryCollection(

/// Get a point from coordinates and feature
GeoJsonPoint getPoint(
{List<dynamic>? coordinates,
GeoJsonFeature<dynamic>? feature,
String? nameProperty}) {
{final List<dynamic>? coordinates,
final GeoJsonFeature<dynamic>? feature,
final String? nameProperty}) {
final name = _getName(feature: feature, nameProperty: nameProperty);
final geoPoint = _getGeoPoints(<dynamic>[coordinates])[0]..name = name;
return GeoJsonPoint(geoPoint: geoPoint, name: name);
}

/// Get multi points from coordinates and feature
GeoJsonMultiPoint getMultiPoint(
{required List<dynamic> coordinates,
GeoJsonFeature<dynamic>? feature,
String? nameProperty}) {
{required final List<dynamic> coordinates,
final GeoJsonFeature<dynamic>? feature,
final String? nameProperty}) {
final multiPoint = GeoJsonMultiPoint();
final name = _getName(feature: feature, nameProperty: nameProperty);
multiPoint.name = name;
Expand All @@ -41,9 +41,9 @@ GeoJsonMultiPoint getMultiPoint(

/// Get a line from coordinates and feature
GeoJsonLine getLine(
{required List<dynamic> coordinates,
GeoJsonFeature<dynamic>? feature,
String? nameProperty}) {
{required final List<dynamic> coordinates,
final GeoJsonFeature<dynamic>? feature,
final String? nameProperty}) {
final line = GeoJsonLine();
final name = _getName(feature: feature, nameProperty: nameProperty);
line.name = name;
Expand All @@ -57,9 +57,9 @@ GeoJsonLine getLine(

/// Get a multi line from coordinates and feature
GeoJsonMultiLine getMultiLine(
{required List<dynamic> coordinates,
GeoJsonFeature<dynamic>? feature,
String? nameProperty}) {
{required final List<dynamic> coordinates,
final GeoJsonFeature<dynamic>? feature,
final String? nameProperty}) {
final name = _getName(feature: feature, nameProperty: nameProperty);
final multiLine = GeoJsonMultiLine(name: name);
var i = 1;
Expand All @@ -79,9 +79,9 @@ GeoJsonMultiLine getMultiLine(

/// Get a polygon from coordinates and feature
GeoJsonPolygon getPolygon(
{required List<dynamic> coordinates,
GeoJsonFeature<dynamic>? feature,
String? nameProperty}) {
{required final List<dynamic> coordinates,
final GeoJsonFeature<dynamic>? feature,
final String? nameProperty}) {
final polygon = GeoJsonPolygon();
final name = _getName(feature: feature, nameProperty: nameProperty);
polygon.name = name;
Expand All @@ -97,9 +97,9 @@ GeoJsonPolygon getPolygon(

/// Get a multiPolygon from coordinates and feature
GeoJsonMultiPolygon getMultiPolygon(
{required List<dynamic> coordinates,
GeoJsonFeature<dynamic>? feature,
String? nameProperty}) {
{required final List<dynamic> coordinates,
final GeoJsonFeature<dynamic>? feature,
final String? nameProperty}) {
final multiPolygon = GeoJsonMultiPolygon();
var i = 1;
multiPolygon.name = _getName(feature: feature, nameProperty: nameProperty);
Expand All @@ -108,7 +108,7 @@ GeoJsonMultiPolygon getMultiPolygon(
final name =
_getName(feature: feature, nameProperty: nameProperty, index: i);
polygon.name = name;
for (final coords in coordsL2) {
for (final coords in coordsL2 as Iterable) {
final geoSerie = GeoSerie(
name: _getName(feature: feature, nameProperty: nameProperty),
type: GeoSerieType.polygon)
Expand All @@ -122,7 +122,9 @@ GeoJsonMultiPolygon getMultiPolygon(
}

String _getName(
{GeoJsonFeature<dynamic>? feature, String? nameProperty, int? index}) {
{final GeoJsonFeature<dynamic>? feature,
final String? nameProperty,
final int? index}) {
String? name;
if (nameProperty != null) {
name = feature?.properties?[nameProperty]?.toString();
Expand All @@ -140,7 +142,7 @@ String _getName(
return name;
}

List<GeoPoint> _getGeoPoints(List<dynamic> coordsList) {
List<GeoPoint> _getGeoPoints(final List<dynamic> coordsList) {
final geoPoints = <GeoPoint>[];
for (final coordinates in coordsList) {
if (!(coordinates is List)) continue; // skip
Expand Down
Loading