-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into auto-format-dc78511
- Loading branch information
Showing
18 changed files
with
2,402 additions
and
445 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Large diffs are not rendered by default.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,103 @@ | ||
import 'dart:convert'; | ||
|
||
import 'package:eqmonitor/schema/local/prefecture/map_polygon.dart'; | ||
import 'package:flutter/cupertino.dart'; | ||
import 'package:flutter/services.dart'; | ||
import 'package:geojson/geojson.dart'; | ||
import 'package:hooks_riverpod/hooks_riverpod.dart'; | ||
import 'package:logger/logger.dart'; | ||
|
||
import '../../utils/map/map_global_offset.dart'; | ||
|
||
/// 市町村等(地震津波関係) | ||
final mapAreaInformationCityQuakeProvider = | ||
Provider<List<MapAreaInformationCityQuakePolygon>>((ref) { | ||
throw UnimplementedError(); | ||
}); | ||
|
||
class MapAreaInformationCityQuakePolygon extends MapPolygon { | ||
const MapAreaInformationCityQuakePolygon({ | ||
required super.code, | ||
required super.name, | ||
required super.path, | ||
required super.points, | ||
required this.regionname, | ||
}); | ||
|
||
final String regionname; | ||
} | ||
|
||
Future<List<MapAreaInformationCityQuakePolygon>> | ||
loadMapAreaInformationCityQuake() async { | ||
final stopwatch = Stopwatch()..start(); | ||
final geo = GeoJson(); | ||
final logger = Logger(); | ||
|
||
final mapPaths = <MapAreaInformationCityQuakePolygon>[]; | ||
|
||
geo.processedFeatures.listen((feature) { | ||
if (feature.type == GeoJsonFeatureType.multipolygon) { | ||
final geometry = feature.geometry as GeoJsonMultiPolygon; | ||
for (final polygon in geometry.polygons) { | ||
for (final geoSeries in polygon.geoSeries) { | ||
if (feature.properties!['regioncode'] == null) { | ||
continue; | ||
} | ||
final tmpPoints = <Offset>[]; | ||
for (final geoPoint in geoSeries.geoPoints) { | ||
final offset = MapGlobalOffset.latLonToGlobalPoint(geoPoint.point) | ||
.toLocalOffset(const Size(476, 927.4)); | ||
tmpPoints.add(offset); | ||
} | ||
mapPaths.add( | ||
MapAreaInformationCityQuakePolygon( | ||
code: int.parse(feature.properties!['regioncode'].toString()), | ||
name: feature.properties!['name'].toString(), | ||
path: Path()..addPolygon(tmpPoints, true), | ||
points: tmpPoints, | ||
regionname: feature.properties!['regionname'].toString(), | ||
), | ||
); | ||
} | ||
} | ||
} else if (feature.type == GeoJsonFeatureType.polygon) { | ||
final geometry = feature.geometry as GeoJsonPolygon; | ||
for (final geoSeries in geometry.geoSeries) { | ||
if (feature.properties!['regioncode'] == null) { | ||
continue; | ||
} | ||
final tmpPoints = <Offset>[]; | ||
for (final geoPoint in geoSeries.geoPoints) { | ||
final offset = MapGlobalOffset.latLonToGlobalPoint(geoPoint.point) | ||
.toLocalOffset(const Size(476, 927.4)); | ||
tmpPoints.add(offset); | ||
} | ||
mapPaths.add( | ||
MapAreaInformationCityQuakePolygon( | ||
code: int.parse(feature.properties!['regioncode'].toString()), | ||
name: feature.properties!['name'].toString(), | ||
path: Path()..addPolygon(tmpPoints, true), | ||
points: tmpPoints, | ||
regionname: feature.properties!['regionname'].toString(), | ||
), | ||
); | ||
} | ||
} | ||
}); | ||
geo.endSignal.listen((_) { | ||
stopwatch.stop(); | ||
logger.i( | ||
'mapAreaInformationCityQuakeを読み込みました: ' | ||
'${stopwatch.elapsedMicroseconds / 1000}ms\n' | ||
'読み込んだ数: ${mapPaths.length}', | ||
); | ||
}); | ||
await geo.parse( | ||
utf8.decode( | ||
(await rootBundle.load('assets/maps/AreaInformationCityQuake.json')) | ||
.buffer | ||
.asUint8List(), | ||
), | ||
); | ||
return mapPaths; | ||
} |
This file contains 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
Oops, something went wrong.