|
@@ -1,94 +0,0 @@
|
|
|
-package cn.com.taiji.cql.service.impl;
|
|
|
-import cn.com.taiji.cql.config.GeoConfig;
|
|
|
-import cn.com.taiji.cql.model.GeoDataSource;
|
|
|
-import cn.com.taiji.cql.model.GeoRequestParam;
|
|
|
-import cn.com.taiji.cql.service.IECqlService;
|
|
|
-import cn.com.taiji.cql.service.ITileService;
|
|
|
-import cn.com.taiji.tile.util.TileUtils;
|
|
|
-import com.alibaba.fastjson.JSONObject;
|
|
|
-import lombok.extern.slf4j.Slf4j;
|
|
|
-import org.geotools.jdbc.JDBCDataStoreFactory;
|
|
|
-import org.springframework.beans.factory.annotation.Autowired;
|
|
|
-import org.springframework.stereotype.Service;
|
|
|
-
|
|
|
-import java.util.HashMap;
|
|
|
-import java.util.List;
|
|
|
-import java.util.Map;
|
|
|
-
|
|
|
-@Slf4j
|
|
|
-@Service
|
|
|
-public class TileServiceImpl implements ITileService {
|
|
|
-
|
|
|
- @Autowired
|
|
|
- private IECqlService ecqlService;
|
|
|
-
|
|
|
- @Autowired
|
|
|
- private GeoConfig geoConfig;
|
|
|
-
|
|
|
-
|
|
|
- @Override
|
|
|
- public byte[] tileData(GeoRequestParam requestParam) {
|
|
|
-
|
|
|
- //1先根据图层代码获取对应的数据源
|
|
|
- Map<String, Object> mapParams = new HashMap<String, Object>();
|
|
|
- mapParams.put(JDBCDataStoreFactory.DATABASE.key, geoConfig.getDsBase());
|
|
|
- mapParams.put(JDBCDataStoreFactory.DBTYPE.key, geoConfig.getDbType());
|
|
|
-
|
|
|
- mapParams.put(JDBCDataStoreFactory.HOST.key, geoConfig.getDsIp());
|
|
|
- mapParams.put(JDBCDataStoreFactory.PORT.key, geoConfig.getDsPort());
|
|
|
- mapParams.put(JDBCDataStoreFactory.USER.key, geoConfig.getDsUsername());
|
|
|
- mapParams.put(JDBCDataStoreFactory.PASSWD.key, geoConfig.getDsPassword());
|
|
|
- mapParams.put("tableName", "geo_data_source");
|
|
|
-
|
|
|
- String layerCodeCql = "layer_code='"+requestParam.getLayers()+"'";
|
|
|
- List<Map<String, Object>> dataSourceList = ecqlService.cqlQuery(mapParams,layerCodeCql);
|
|
|
-
|
|
|
- if(dataSourceList.size() >0){
|
|
|
-
|
|
|
-
|
|
|
- //2根据cql规则获取图层对应的空间地理数据
|
|
|
-
|
|
|
- GeoDataSource gds = JSONObject.parseObject(JSONObject.toJSONString(dataSourceList.get(0)), GeoDataSource.class);
|
|
|
-
|
|
|
-
|
|
|
- StringBuffer sbBbox = new StringBuffer();
|
|
|
- sbBbox.append("(bbox (");
|
|
|
- sbBbox.append(gds.getBboxColumn()+",");
|
|
|
- sbBbox.append(requestParam.getBbox()+"))");
|
|
|
-
|
|
|
-
|
|
|
- String filterCql = requestParam.getCqlFilter()+" and "+sbBbox.toString();
|
|
|
-
|
|
|
- Map<String, Object> cqlDsParams = new HashMap<String, Object>();
|
|
|
- cqlDsParams.put(JDBCDataStoreFactory.DATABASE.key, gds.getDataBase());
|
|
|
- cqlDsParams.put(JDBCDataStoreFactory.DBTYPE.key, gds.getDbType());
|
|
|
-
|
|
|
- cqlDsParams.put(JDBCDataStoreFactory.HOST.key, gds.getHost());
|
|
|
- cqlDsParams.put(JDBCDataStoreFactory.PORT.key, gds.getPort());
|
|
|
- cqlDsParams.put(JDBCDataStoreFactory.USER.key, gds.getUserName());
|
|
|
- cqlDsParams.put(JDBCDataStoreFactory.PASSWD.key, gds.getUserPassword());
|
|
|
- cqlDsParams.put("tableName", gds.getTableName());
|
|
|
-
|
|
|
- List<Map<String, Object>> cqlDataList = ecqlService.cqlQuery(cqlDsParams,filterCql);
|
|
|
-
|
|
|
- if(cqlDataList.size() >0){
|
|
|
- //3根据空间地理数据生成图层二进制数据
|
|
|
- System.out.println("返回的数据:"+cqlDataList.toString());
|
|
|
- return TileUtils.getTile(cqlDataList, requestParam.getBbox());
|
|
|
-
|
|
|
- }else{
|
|
|
-
|
|
|
- log.info("根据cql规则:"+sbBbox.toString()+"和图层代码:" + requestParam.getLayers() + " 没有找到图层对应的数据源的空间地理数据");
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- }else{
|
|
|
-
|
|
|
- log.info("根据图层代码:" + requestParam.getLayers() + "获取图层对应的数据源为空或者为null");
|
|
|
- }
|
|
|
-
|
|
|
- return new byte[0];
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
-}
|