Closed xiaomaxuetu closed 5 months ago
Do you have a minimal reproducible example of your issue?
It might an issue directly with the fact that we manipulate an uri using strings instead of the Uri
object, which helps in encoding correctly its properties.
Do you have a minimal reproducible example of your issue? It might an issue directly with the fact that we manipulate an uri using strings instead of the
Uri
object, which helps in encoding correctly its properties.
I receive a wms url from server (split into multiple lines for better readability)
{domain}/geoservercloud-api/tiff/wms?
bbox={bbox-epsg-3857}&
format=image/png&service=WMS&
version=1.1.1&
request=GetMap&
srs=EPSG:3857&
transparent=true&width=256&height=256&
layers=tiff:HS_DEM_20230000_1742023660365344770&
styles=HS_DEM_20230000_empty_default_1742023711514882049&
clip=MULTIPOLYGON (((13936961.4541107 6264501.18326346, 13937513.2339086 6264582.39760601, 13937658.9419938 6263595.8822097, 13937613.5575082 6263581.5502669, 13937561.0070513 6263579.16160977, 13937262.4249096 6263887.29838004, 13937231.3723668 6263782.19746615, 13937231.3723668 6263715.3150664, 13937221.8177383 6263646.04400952, 13937291.0887952 6263583.93892403, 13937353.1938806 6263574.3842955, 13937403.3556805 6263574.3842955, 13937381.8577663 6263531.38846709, 13937219.4290811 6263505.11323861, 13937095.2189102 6263495.55861008, 13936961.4541107 6264501.18326346)))
then deal it with these code
String temp = serverUrl;
if (temp.contains("{domain}")) {
//加载wms
String url = temp.substring(8, temp.length - 1);
String wholeUrl = "${urlConfig.oneMapApi}$url";
Uri uri = Uri.parse(wholeUrl);
var baseUrl = uri.origin + uri.path;
var wmsLayers = uri.queryParameters["layers"];
var styles = uri.queryParameters["styles"];
var format = uri.queryParameters["format"];
var transparent = uri.queryParameters["transparent"];
var clip = uri.queryParameters["clip"];
tempLayers.add(TileLayer(
wmsOptions: WMSTileLayerOptions(
baseUrl: "$baseUrl/?",
layers: [wmsLayers ?? ""],
styles: [styles ?? ""],
format: format ?? "image/png",
transparent: transparent == "true" ? true : false,
otherParameters: {"clip": clip ?? ""}),
));
}
I find that method getUrl in wms_tile_layer_options.dart
String getUrl(TileCoordinates coords, int tileSize, bool retinaMode) {
final tileSizePoint = Point(tileSize, tileSize);
final nwPoint = coords.scaleBy(tileSizePoint);
final sePoint = nwPoint + tileSizePoint;
final nwCoords = crs.pointToLatLng(nwPoint, coords.z.toDouble());
final seCoords = crs.pointToLatLng(sePoint, coords.z.toDouble());
final nw = crs.projection.project(nwCoords);
final se = crs.projection.project(seCoords);
final bounds = Bounds(nw, se);
final bbox = (_versionNumber >= 1.3 && crs is Epsg4326)
? [bounds.min.y, bounds.min.x, bounds.max.y, bounds.max.x]
: [bounds.min.x, bounds.min.y, bounds.max.x, bounds.max.y];
final buffer = StringBuffer(_encodedBaseUrl);
buffer.write('&width=${retinaMode ? tileSize * 2 : tileSize}');
buffer.write('&height=${retinaMode ? tileSize * 2 : tileSize}');
buffer.write('&bbox=${bbox.join(',')}');
return buffer.toString();
}
}
because the clip parmeter is too long, buffer.write('&bbox=${bbox.join(',')}')
will loss
https://img.nj.gov/imagerywms/Natural2015?
bbox={bbox-epsg-3857}&
format=image/png&
service=WMS&
version=1.1.1&
request=GetMap&
srs=EPSG:3857&
transparent=true&width=256&height=256&
layers=Natural2015
This is demo url that used in WMS Layer in mapbox: https://docs.mapbox.com/mapbox-gl-js/example/wms/
Is there any way to use in Flutter map wms layer option?
If this bug still exists, I'm not sure there's too much we can do about it. As far as I can see, we're doing everything OK. Maybe Uri
can't handle it, or there's a length limit somewhere, but some preliminary searching doesn't return any similar issues.
If you can still reproduce this, please let me know, and I'll look into it more. Thanks for the report!
What is the bug?
the StringBuffer.write can not get a complete url,if some parameter too long like this
How can we reproduce it?
bbox=13937221.989405897,6262944.349574201,13938444.981858458,6264167.342026763&format=image/png&service=WMS&version=1.1.1&request=GetMap&srs=EPSG:3857&transparent=true&width=256&height=256&layers=tiff:HS_DEM_20230000_1742023660365344770&styles=HS_DEM_20230000_empty_default_1742023711514882049&clip=MULTIPOLYGON%20(((13936961.4541107%206264501.18326346,%2013937513.2339086%206264582.39760601,%2013937658.9419938%206263595.8822097,%2013937613.5575082%206263581.5502669,%2013937561.0070513%206263579.16160977,%2013937262.4249096%206263887.29838004,%2013937231.3723668%206263782.19746615,%2013937231.3723668%206263715.3150664,%2013937221.8177383%206263646.04400952,%2013937291.0887952%206263583.93892403,%2013937353.1938806%206263574.3842955,%2013937403.3556805%206263574.3842955,%2013937381.8577663%206263531.38846709,%2013937219.4290811%206263505.11323861,%2013937095.2189102%206263495.55861008,%2013936961.4541107%206264501.18326346)))
Do you have a potential solution?
No response
Platforms
Android 13 redmi k40
Severity
Obtrusive: Prevents normal functioning but causes no errors in the console