Skip to content

Commit

Permalink
inital code gen
Browse files Browse the repository at this point in the history
  • Loading branch information
felix-ht committed Nov 30, 2021
1 parent 323afd2 commit 96209aa
Show file tree
Hide file tree
Showing 14 changed files with 1,358 additions and 307 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -376,4 +376,48 @@ static PropertyValue[] interpretFillLayerProperties(Object o) {
return properties.toArray(new PropertyValue[properties.size()]);
}

static PropertyValue[] interpretRasterLayerProperties(Object o) {
final Map<String, String> data = (Map<String, String>) toMap(o);
final List<PropertyValue> properties = new LinkedList();
final JsonParser parser = new JsonParser();

for (Map.Entry<String, String> entry : data.entrySet()) {
final JsonElement jsonElement = parser.parse(entry.getValue());
Expression expression = Expression.Converter.convert(jsonElement);
switch (entry.getKey()) {
case "raster-opacity":
properties.add(PropertyFactory.rasterOpacity(expression));
break;
case "raster-hue-rotate":
properties.add(PropertyFactory.rasterHueRotate(expression));
break;
case "raster-brightness-min":
properties.add(PropertyFactory.rasterBrightnessMin(expression));
break;
case "raster-brightness-max":
properties.add(PropertyFactory.rasterBrightnessMax(expression));
break;
case "raster-saturation":
properties.add(PropertyFactory.rasterSaturation(expression));
break;
case "raster-contrast":
properties.add(PropertyFactory.rasterContrast(expression));
break;
case "raster-resampling":
properties.add(PropertyFactory.rasterResampling(expression));
break;
case "raster-fade-duration":
properties.add(PropertyFactory.rasterFadeDuration(expression));
break;
case "visibility":
properties.add(PropertyFactory.visibility(entry.getValue()));
break;
default:
break;
}
}

return properties.toArray(new PropertyValue[properties.size()]);
}

}
38 changes: 38 additions & 0 deletions ios/Classes/LayerPropertyConverter.swift
Original file line number Diff line number Diff line change
Expand Up @@ -334,6 +334,44 @@ class LayerPropertyConverter {
}
}

class func addRasterProperties(rasterLayer: MGLRasterStyleLayer, properties: [String: String]) {
for (propertyName, propertyValue) in properties {
let expression = interpretExpression(propertyName: propertyName, expression: propertyValue)
switch propertyName {
case "raster-opacity":
rasterLayer.rasterOpacity = expression;
break;
case "raster-hue-rotate":
rasterLayer.rasterHueRotation = expression;
break;
case "raster-brightness-min":
rasterLayer.rasterBrightnessMin = expression;
break;
case "raster-brightness-max":
rasterLayer.rasterBrightnessMax = expression;
break;
case "raster-saturation":
rasterLayer.rasterSaturation = expression;
break;
case "raster-contrast":
rasterLayer.rasterContrast = expression;
break;
case "raster-resampling":
rasterLayer.rasterResamplingMode = expression;
break;
case "raster-fade-duration":
rasterLayer.rasterFadeDuration = expression;
break;
case "visibility":
rasterLayer.isVisible = propertyValue == "visible";
break;

default:
break
}
}
}

private class func interpretExpression(propertyName: String, expression: String) -> NSExpression? {
let isColor = propertyName.contains("color");

Expand Down
8 changes: 8 additions & 0 deletions ios/Classes/MapboxMapController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -748,6 +748,14 @@ class MapboxMapController: NSObject, FlutterPlatformView, MGLMapViewDelegate, Ma
addSource(sourceId: sourceId, geojson: geojson)
result(nil)

case "style#addSource":
guard let arguments = methodCall.arguments as? [String: Any] else { return }
guard let sourceId = arguments["sourceId"] as? String else { return }
guard let geojson = arguments["geojson"] as? String else { return }
addSource(sourceId: sourceId, geojson: geojson)
result(nil)


case "source#setGeoJson":
guard let arguments = methodCall.arguments as? [String: Any] else { return }
guard let sourceId = arguments["sourceId"] as? String else { return }
Expand Down
9 changes: 8 additions & 1 deletion lib/mapbox_gl.dart
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,14 @@ export 'package:mapbox_gl_platform_interface/mapbox_gl_platform_interface.dart'
Line,
LineOptions,
Fill,
FillOptions;
FillOptions,
Source,
RasterSource,
VectorSource,
RasterDemSource,
GeojsonSource,
VideoSource,
ImageSource;

part 'src/controller.dart';
part 'src/mapbox_map.dart';
Expand Down
Loading

0 comments on commit 96209aa

Please sign in to comment.