蓝牙绑定设备+场站切换支持高清图层的一对一显示+设备实时状态的部分显示
This commit is contained in:
@@ -7,17 +7,46 @@ import 'package:latlong2/latlong.dart';
|
||||
/// GeoServer 基地址(公司端)
|
||||
const String kGeoserverBase = 'http://1.95.137.212:7900/geoserver';
|
||||
|
||||
/// 首期苏州区域图层标识
|
||||
const String kSuzhouLayerName = 'workSpace:suzhou';
|
||||
/// 各场站高清图层的真实范围(取自 GeoServer GetCapabilities,原生 EPSG:4326)
|
||||
/// key = 后端下发的 siteMapName(形如 workSpace:suzhou)
|
||||
final Map<String, LatLngBounds> kStationLayerBounds = {
|
||||
'workSpace:liaoding': LatLngBounds(
|
||||
const LatLng(41.19998369457442, 120.59074514010273),
|
||||
const LatLng(41.202002066385475, 120.59343722827124),
|
||||
),
|
||||
'workSpace:loudi': LatLngBounds(
|
||||
const LatLng(27.846682995656035, 111.52814279952669),
|
||||
const LatLng(27.847939704917945, 111.52928081352842),
|
||||
),
|
||||
'workSpace:neimeng': LatLngBounds(
|
||||
const LatLng(41.321581124009896, 112.62468603332228),
|
||||
const LatLng(41.325573311689986, 112.63034797059984),
|
||||
),
|
||||
'workSpace:result': LatLngBounds(
|
||||
const LatLng(27.36490549568922, 116.84490756003203),
|
||||
const LatLng(27.36673908366302, 116.84661654295478),
|
||||
),
|
||||
'workSpace:sanxiamen': LatLngBounds(
|
||||
const LatLng(34.732748259670494, 111.43051478686061),
|
||||
const LatLng(34.734205267863345, 111.43201022647355),
|
||||
),
|
||||
'workSpace:suzhou': LatLngBounds(
|
||||
const LatLng(31.082450793459877, 120.83906484264836),
|
||||
const LatLng(31.084141983135456, 120.84164596446476),
|
||||
),
|
||||
'workSpace:zhongke': LatLngBounds(
|
||||
const LatLng(32.0406442971753, 120.8057183175354),
|
||||
const LatLng(32.045144217672636, 120.81100452381844),
|
||||
),
|
||||
};
|
||||
|
||||
/// 苏州图层实际覆盖范围(取自 GetCapabilities,约 250m × 190m 的小地块)
|
||||
final LatLngBounds kSuzhouBounds = LatLngBounds(
|
||||
const LatLng(31.082450793459877, 120.83906484264836),
|
||||
const LatLng(31.084141983135456, 120.84164596446476),
|
||||
);
|
||||
|
||||
/// 场站中心点(真实地块中心)
|
||||
const LatLng kSuzhouCenter = LatLng(31.083296, 120.840355);
|
||||
/// 取某场站图层的范围中心点(用作进场默认定位);未知/为空返回 null
|
||||
LatLng? stationLayerCenter(String? siteMapName) {
|
||||
if (siteMapName == null) return null;
|
||||
final b = kStationLayerBounds[siteMapName];
|
||||
if (b == null) return null;
|
||||
return LatLng((b.south + b.north) / 2, (b.west + b.east) / 2);
|
||||
}
|
||||
|
||||
/// 叠加层取瓦片方式开关:
|
||||
/// - false(当前):WMS GetMap 兜底,不依赖 GWC 缓存
|
||||
@@ -29,8 +58,14 @@ const bool kUseWmtsTile = false;
|
||||
/// 请求 EPSG:3857(WMS 1.1.1 / 1.3.0 均验证过)返回纯白图。
|
||||
/// 因此这里按瓦片 XYZ 反算经纬度 bbox,以 EPSG:4326 请求 WMS。
|
||||
class GeoWmsProvider extends TileProvider {
|
||||
GeoWmsProvider({this.maxLevel = 21});
|
||||
GeoWmsProvider({
|
||||
required this.layerName,
|
||||
required this.bounds,
|
||||
this.maxLevel = 21,
|
||||
});
|
||||
|
||||
final String layerName;
|
||||
final LatLngBounds bounds;
|
||||
final int maxLevel;
|
||||
|
||||
/// Web 墨卡托地球周长(米)
|
||||
@@ -64,10 +99,10 @@ class GeoWmsProvider extends TileProvider {
|
||||
final northLat = _mercatorYToLat(northM);
|
||||
|
||||
// 与图层实际范围不相交的瓦片直接返回透明图,不发无谓请求
|
||||
final intersects = westLng < kSuzhouBounds.east &&
|
||||
eastLng > kSuzhouBounds.west &&
|
||||
southLat < kSuzhouBounds.north &&
|
||||
northLat > kSuzhouBounds.south;
|
||||
final intersects = westLng < bounds.east &&
|
||||
eastLng > bounds.west &&
|
||||
southLat < bounds.north &&
|
||||
northLat > bounds.south;
|
||||
if (!intersects) {
|
||||
return MemoryImage(TileProvider.transparentImage);
|
||||
}
|
||||
@@ -77,7 +112,7 @@ class GeoWmsProvider extends TileProvider {
|
||||
'SERVICE': 'WMS',
|
||||
'REQUEST': 'GetMap',
|
||||
'VERSION': '1.1.1',
|
||||
'LAYERS': kSuzhouLayerName,
|
||||
'LAYERS': layerName,
|
||||
'BBOX': '${westLng.toStringAsFixed(6)},${southLat.toStringAsFixed(6)},'
|
||||
'${eastLng.toStringAsFixed(6)},${northLat.toStringAsFixed(6)}',
|
||||
'WIDTH': '256',
|
||||
@@ -92,11 +127,18 @@ class GeoWmsProvider extends TileProvider {
|
||||
}
|
||||
}
|
||||
|
||||
/// GeoServer 苏州无人机高清影像叠加层(WGS84 基准,覆盖在 ESRI 底图上)
|
||||
///
|
||||
/// 地块很小(约 250m),zoom 16 以上才有意义,默认 minZoom = 16
|
||||
/// GeoServer 场站无人机高清影像叠加层(WGS84 基准,覆盖在 ESRI 底图上)
|
||||
/// 按当前选中场站的 siteMapName 动态加载对应图层;地块很小,默认 minZoom = 16
|
||||
class GeoSuzhouOverlay extends StatelessWidget {
|
||||
const GeoSuzhouOverlay({super.key, this.minZoom = 16, this.maxZoom = 21});
|
||||
const GeoSuzhouOverlay({
|
||||
super.key,
|
||||
this.siteMapName,
|
||||
this.minZoom = 16,
|
||||
this.maxZoom = 21,
|
||||
});
|
||||
|
||||
/// 当前选中场站对应的 GeoServer 图层名(形如 workSpace:suzhou)
|
||||
final String? siteMapName;
|
||||
|
||||
/// 小于该级别不请求瓦片(地块太小,低层级看不见)
|
||||
final double minZoom;
|
||||
@@ -106,28 +148,39 @@ class GeoSuzhouOverlay extends StatelessWidget {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final layer = siteMapName;
|
||||
final bounds = layer == null ? null : kStationLayerBounds[layer];
|
||||
// 未选中场站或图层未知 → 不渲染叠加层
|
||||
if (layer == null || bounds == null) {
|
||||
return const SizedBox.shrink();
|
||||
}
|
||||
|
||||
if (kUseWmtsTile) {
|
||||
// === WMTS 版:公司把 EPSG:3857 gridset 加入 GWC 并 Seed 后生效 ===
|
||||
return TileLayer(
|
||||
urlTemplate: '$kGeoserverBase/gwc/service/wmts'
|
||||
'?SERVICE=WMTS&REQUEST=GetTile&VERSION=1.0.0'
|
||||
'&LAYER=$kSuzhouLayerName&TILEMATRIXSET=EPSG:3857'
|
||||
'&LAYER=$layer&TILEMATRIXSET=EPSG:3857'
|
||||
'&TILEMATRIX={z}&TILEROW={y}&TILECOL={x}&FORMAT=image/png',
|
||||
userAgentPackageName: 'com.example.app',
|
||||
minZoom: minZoom,
|
||||
maxZoom: maxZoom,
|
||||
maxNativeZoom: maxZoom.toInt(),
|
||||
tileBounds: kSuzhouBounds,
|
||||
tileBounds: bounds,
|
||||
);
|
||||
}
|
||||
// === WMS 版(当前兜底):按原生 EPSG:4326 请求,GeoServer 实时渲染 ===
|
||||
return TileLayer(
|
||||
tileProvider: GeoWmsProvider(maxLevel: maxZoom.toInt()),
|
||||
tileProvider: GeoWmsProvider(
|
||||
layerName: layer,
|
||||
bounds: bounds,
|
||||
maxLevel: maxZoom.toInt(),
|
||||
),
|
||||
userAgentPackageName: 'com.example.app',
|
||||
minZoom: minZoom,
|
||||
maxZoom: maxZoom,
|
||||
maxNativeZoom: maxZoom.toInt(),
|
||||
tileBounds: kSuzhouBounds,
|
||||
tileBounds: bounds,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user