toGeoJson<T extends GeoJson<Geometry>> method

T? toGeoJson<T extends GeoJson<Geometry>>({
  1. required int x,
  2. required int y,
  3. required int z,
})

Get GeoJson data from this feature

x, y, z: is tile numbers and tile zoom x, y, z was used to calculate lon/lat pairs

Return generic GeoJson type, there are two ways to to read data returned from this method:

  • Explicit given a generic type:
     var geojson = feature.toGeoJson<GeoJsonPoint>(3262, 1923, 12);
     var coordinates = geojson.geometry.coordinates;
    
  • Cast to specific GeoJson type after got returned data:
     var geojson = feature.toGeoJson(3262, 1923, 12);
     var coordinates = (geojson as GeoJsonPoint).geometry.coordinates;
    

Implementation

T? toGeoJson<T extends GeoJson>(
    {required int x, required int y, required int z}) {
  if (this.geometry == null) {
    this.decodeGeometry();
  }

  int size = this.extent! * (pow(2, z) as int);
  int x0 = this.extent! * x;
  int y0 = this.extent! * y;

  return this.toGeoJsonWithExtentCalculated<T>(x0: x0, y0: y0, size: size);
}