Merge branch 'master' of gitlab.navinfo.com:CollectVehicle/OneMapQS

 Conflicts:
	vtm
This commit is contained in:
squallzhjch 2023-08-31 15:33:15 +08:00
commit e4aa29ea32
6 changed files with 115 additions and 10 deletions

View File

@ -167,6 +167,22 @@
}
]
},
"3002":{
"table": "OMDB_OBJECT_TEXT",
"code": 3002,
"name": "文字",
"zoomMin": 15,
"zoomMax": 20,
"transformer2Code": ""
},
"3003":{
"table": "OMDB_OBJECT_SYMBOL",
"code": 3003,
"name": "符号",
"zoomMin": 15,
"zoomMax": 20,
"transformer2Code": ""
},
"3005":{
"table": "OMDB_TRAFFIC_SIGN",
"code": 3005,
@ -211,7 +227,7 @@
"table": "OMDB_CROSS_WALK",
"code": 3014,
"name": "人行横道",
"zoomMin": 18,
"zoomMin": 15,
"zoomMax": 20
},
"3016":{

View File

@ -129,7 +129,7 @@ class PersonalCenterFragment(private var indoorDataListener: ((Boolean) -> Unit?
// 定位到指定位置
niMapController.mMapView.vtmMap.animator()
// .animateTo(GeoPoint( 40.05108004733645, 116.29187746293708 ))
.animateTo(GeoPoint( 40.45250049995882, 115.85967482434108 ))
.animateTo(GeoPoint( 40.480633792652746, 115.99816629572948 ))
}
R.id.personal_center_menu_open_all_layer -> {
MapParamUtils.setDataLayerEnum(DataLayerEnum.SHOW_ALL_LAYERS)

View File

@ -147,6 +147,8 @@
<xs:attribute name="repeat" default="true" type="xs:boolean" use="optional"/>
<!-- 长边坐标轴默认为s -->
<xs:attribute name="longEdge" type="tns:text" default="s"/>
<!-- 是否包含方向默认为false -->
<xs:attribute name="hasDirect" default="false" type="xs:boolean" use="optional" />
</xs:complexType>
<xs:complexType name="caption">

View File

@ -1491,10 +1491,10 @@
</m>
<m k="qi_table">
<!-- &lt;!&ndash; 道路线 &ndash;&gt;-->
<!-- <m v="OMDB_RD_LINK">-->
<!-- <line stroke="#9c9c9c" width="1" />-->
<!-- </m>-->
<!-- 道路线 -->
<m v="OMDB_RD_LINK">
<line stroke="#9c9c9c" width="1" />
</m>
<!--道路种别-->
<m v="OMDB_RD_LINK_KIND">
@ -2330,10 +2330,18 @@
<!-- <area use="obj-area" repeat="false"></area>-->
<!-- <symbol src="assets:omdb/icon_fill_area_3012.svg"></symbol>-->
</m>
<!-- 文字 -->
<m v="OMDB_OBJECT_TEXT">
<area use="obj-area" repeat="false" src="@text-src:textString" longEdge="t" hasDirect="true"></area>
</m>
<!-- 符号 -->
<m v="OMDB_OBJECT_SYMBOL">
<area use="obj-area" repeat="false" src="assets:omdb/tex_fill_area_3012.png" longEdge="t" hasDirect="true"></area>
</m>
<!-- 人行横道 -->
<m v="OMDB_CROSS_WALK">
<area use="obj-area" fill="#00000000" stroke="#00000000" repeat="true" src="assets:omdb/tex_fill_area_3014_4.svg" longEdge="s"></area>
<area use="obj-area" stroke="#00000000" repeat="true" src="assets:omdb/tex_fill_area_3014_3.png" longEdge="s"></area>
</m>
<!-- 道路施工 -->

View File

@ -6,6 +6,7 @@ import com.navinfo.collect.library.data.entity.RenderEntity
import com.navinfo.collect.library.map.NIMapView
import com.navinfo.collect.library.map.source.MapLifeNiLocationTileSource
import com.navinfo.collect.library.map.source.NavinfoMultiMapFileTileSource
import com.navinfo.collect.library.map.source.NavinfoTileThemeHook
import com.navinfo.collect.library.map.source.OMDBReferenceTileSource
import com.navinfo.collect.library.map.source.OMDBTileSource
import com.navinfo.collect.library.system.Constant
@ -57,6 +58,8 @@ class LayerManagerHandler(context: AppCompatActivity, mapView: NIMapView, traceP
private val omdbTileSource by lazy { OMDBTileSource() }
private val omdbReferenceTileSource by lazy { OMDBReferenceTileSource() }
private val labelTileLoaderHook = LabelTileLoaderHook()
private val navinfoTileThemeHook = NavinfoTileThemeHook()
init {
initMap()
@ -76,7 +79,7 @@ class LayerManagerHandler(context: AppCompatActivity, mapView: NIMapView, traceP
vectorNiLocationTileLayer = VectorTileLayer(mMapView.vtmMap, mapLifeNiLocationTileSource)
labelNiLocationLayer =
LabelLayer(mMapView.vtmMap, vectorNiLocationTileLayer, LabelTileLoaderHook())
LabelLayer(mMapView.vtmMap, vectorNiLocationTileLayer, labelTileLoaderHook)
if (vectorNiLocationTileLayer != null) {
addLayer(vectorNiLocationTileLayer, NIMapView.LAYER_GROUPS.BASE)
@ -114,7 +117,7 @@ class LayerManagerHandler(context: AppCompatActivity, mapView: NIMapView, traceP
omdbReferenceLabelLayer = LabelLayer(
mMapView.vtmMap,
omdbReferenceTileLayer,
LabelTileLoaderHook()
labelTileLoaderHook
)
if (omdbReferenceTileLayer != null) {
addLayer(omdbReferenceTileLayer, NIMapView.LAYER_GROUPS.VECTOR_TILE)
@ -127,7 +130,7 @@ class LayerManagerHandler(context: AppCompatActivity, mapView: NIMapView, traceP
omdbLabelLayer = LabelLayer(
mMapView.vtmMap,
omdbVectorTileLayer,
LabelTileLoaderHook()
labelTileLoaderHook
)
if (omdbVectorTileLayer != null) {
addLayer(omdbVectorTileLayer, NIMapView.LAYER_GROUPS.VECTOR_TILE)
@ -135,6 +138,9 @@ class LayerManagerHandler(context: AppCompatActivity, mapView: NIMapView, traceP
if (omdbLabelLayer != null) {
addLayer(omdbLabelLayer, NIMapView.LAYER_GROUPS.LABEL)
}
// 向两个Vector图层增加hook钩子加载数据前对style或数据进行二次处理
omdbVectorTileLayer.addHook(navinfoTileThemeHook)
omdbReferenceTileLayer.addHook(navinfoTileThemeHook)
}
private fun resetOMDBVectorTileLayer() {

View File

@ -0,0 +1,73 @@
package com.navinfo.collect.library.map.source;
import org.oscim.core.MapElement;
import org.oscim.layers.tile.MapTile;
import org.oscim.layers.tile.vector.VectorTileLayer;
import org.oscim.renderer.bucket.RenderBuckets;
import org.oscim.theme.styles.RenderStyle;
import java.util.HashMap;
import java.util.Map;
/**
* 数据在加载前对MapElement做处理
*
* */
public class NavinfoTileThemeHook implements VectorTileLayer.TileLoaderThemeHook {
// 缓存样式如果存在相同的文字图片从缓存直接获取
private Map<String, RenderStyle> styleMap = new HashMap<>();
@Override
public boolean process(MapTile tile, RenderBuckets buckets, MapElement element, RenderStyle style, int level) {
// if (style instanceof AreaStyle) {
// AreaStyle area = (AreaStyle) style;
// if (area.src!=null&&area.texture==null) {
// String textValue = null;
// if (area.src.startsWith("@text-src:")) {
// String tagKey = area.src.replace("@text-src:", "");
// // 根据配置的tagKey获取对应的文字值
// textValue = element.tags.getValue(tagKey);
// } else if (area.src.startsWith("@text:")) {
// // 构建一个文字图片
// textValue = area.src.substring(5);
// }
//
// // 使用文本值生成纹理图片
// if (textValue==null) {
// return false;
// }
//
// // 根据引用字段生成新的style样式
// RenderStyle cacheStyle = styleMap.get(textValue);
// if (cacheStyle!=null) {
// style.set(cacheStyle);
// } else { // 不存在缓存style需要按照文字生成对应的图片纹理
// AreaStyle.AreaBuilder<?> builder = new AreaStyle.AreaBuilder();
// builder.set((AreaStyle) style);
// // 构建一个文字图片
// Canvas canvas = CanvasAdapter.newCanvas();
// Paint paint = CanvasAdapter.newPaint();
// paint.setColor(Color.WHITE);
// paint.setTextSize(15);
//
// Bitmap bitmap = CanvasAdapter.newBitmap(Math.round(paint.getTextWidth(textValue)+10), Math.round(paint.getTextHeight(textValue)+10), 0);
// canvas.setBitmap(bitmap);
// canvas.drawText(textValue, 5
// , 5+paint.getTextHeight(textValue), paint, paint);
// builder.texture = new TextureItem(Utils.potBitmap(bitmap), area.repeat);
// builder.src = null; // 清空原有的带@的src配置
// area = builder.build();
// styleMap.put(textValue, area);
// style.set(area);
// }
// }
// }
// style.update();
return false; // 如果返回true后续的hook将不会执行
}
@Override
public void complete(MapTile tile, boolean success) {
}
}