|
@@ -2005,95 +2005,125 @@ const resetLandPanel = () => {
|
|
|
};
|
|
|
//供地geoserver
|
|
|
const queryGDByGeoServerFeature = (geo) => {
|
|
|
- var cksj = null;
|
|
|
- const currentYear = new Date().getFullYear();
|
|
|
- //string格式
|
|
|
- // for (var i = 0; i < form.value.formItem.cksj; i++) {
|
|
|
- // var year = currentYear - i;
|
|
|
- // if (i == 0) {
|
|
|
- // cksj = `(qdrq like '%${year}%'`;
|
|
|
- // } else {
|
|
|
- // cksj += ` or qdrq like '%${year}%'`;
|
|
|
- // }
|
|
|
- // }
|
|
|
- // cksj += ')';
|
|
|
- // timestamp 时间格式
|
|
|
- const preYear = currentYear - form.value.formItem.cksj;
|
|
|
- var start = preYear + '-01-01';
|
|
|
- var end = currentYear + '-12-31';
|
|
|
- cksj = `(qdrq >= '%${start}%' and qdrq <='%${end}%')`;
|
|
|
+ // 1. 构造 GML Polygon
|
|
|
+ const rings = geo.rings[0];
|
|
|
+ const posList = rings.map(pt => pt.join(' ')).join(' ');
|
|
|
|
|
|
- var tdyt = `tdytmc like '%${form.value.formItem.tdyt}%'`;
|
|
|
- if (form.value.formItem.tdyt == '商服') {
|
|
|
- tdyt = `tdytmc like '%商%'and tdytmc not like '%住%'`;
|
|
|
- }
|
|
|
- if (form.value.formItem.tdyt == '工业') {
|
|
|
- tdyt = `(tdytmc like '%工%' or tdytmc like '%仓%' or tdytmc like '%矿%')`;
|
|
|
- }
|
|
|
- if (form.value.formItem.tdyt == '住宅') {
|
|
|
- tdyt = `tdytmc like '%住%'`;
|
|
|
- }
|
|
|
- if (form.value.formItem.tdyt == '其他') {
|
|
|
- tdyt = `tdytmc not like '%住%' and tdytmc not like '%商%' and tdytmc not like '%工%' and tdytmc not like '%矿%' and tdytmc not like '%仓%'`;
|
|
|
+ // 2. 构造 XML Filter
|
|
|
+ const tdytmc = form.value.formItem.tdyt;
|
|
|
+ let tdytLike = '%';
|
|
|
+ if (tdytmc === '商服') tdytLike = '%商%';
|
|
|
+ else if (tdytmc === '工业') tdytLike = '%工%';
|
|
|
+ else if (tdytmc === '住宅') tdytLike = '%住%';
|
|
|
+ else if (tdytmc === '其他') tdytLike = '%其他%';
|
|
|
+
|
|
|
+ const xml = `
|
|
|
+<wfs:GetFeature
|
|
|
+ service="WFS"
|
|
|
+ version="1.1.0"
|
|
|
+ outputFormat="application/json"
|
|
|
+ xmlns:wfs="http://www.opengis.net/wfs"
|
|
|
+ xmlns:ogc="http://www.opengis.net/ogc"
|
|
|
+ xmlns:gml="http://www.opengis.net/gml"
|
|
|
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
|
|
+ xsi:schemaLocation="http://www.opengis.net/wfs http://schemas.opengis.net/wfs/1.1.0/wfs.xsd">
|
|
|
+ <wfs:Query typeName="cyzz:gdxminfo_all">
|
|
|
+ <ogc:Filter>
|
|
|
+ <ogc:And>
|
|
|
+ <ogc:Intersects>
|
|
|
+ <ogc:PropertyName>shape</ogc:PropertyName>
|
|
|
+ <gml:Polygon srsName="EPSG:4490">
|
|
|
+ <gml:exterior>
|
|
|
+ <gml:LinearRing>
|
|
|
+ <gml:posList>
|
|
|
+ ${posList}
|
|
|
+ </gml:posList>
|
|
|
+ </gml:LinearRing>
|
|
|
+ </gml:exterior>
|
|
|
+ </gml:Polygon>
|
|
|
+ </ogc:Intersects>
|
|
|
+ <ogc:PropertyIsLike wildCard="%" singleChar="_" escape="!">
|
|
|
+ <ogc:PropertyName>tdytmc</ogc:PropertyName>
|
|
|
+ <ogc:Literal>${tdytLike}</ogc:Literal>
|
|
|
+ </ogc:PropertyIsLike>
|
|
|
+ </ogc:And>
|
|
|
+ </ogc:Filter>
|
|
|
+ </wfs:Query>
|
|
|
+</wfs:GetFeature>`;
|
|
|
+
|
|
|
+ // 3. 发送 POST 请求
|
|
|
+ let url = window.AppGlobalConfig.owsLandUrl;
|
|
|
+ // 保证url带有outputFormat参数,确保响应为json
|
|
|
+ if (url.indexOf('?') === -1) {
|
|
|
+ url += '?outputFormat=application%2Fjson';
|
|
|
+ } else if (!/outputFormat=/.test(url)) {
|
|
|
+ url += '&outputFormat=application%2Fjson';
|
|
|
}
|
|
|
- var sql = cksj + ` and ` + tdyt;
|
|
|
- var query = encodeURI(sql);
|
|
|
- var origGeo = arcgisToGeoJSON(geo);
|
|
|
- var wktString = wkt.convert(origGeo);
|
|
|
- var landUrl = window.AppGlobalConfig.landGeoserverUrl;
|
|
|
- var ows = window.AppGlobalConfig.owsLandUrl;
|
|
|
- var geoField = window.AppGlobalConfig.landGeoField;
|
|
|
- var geoServerUrl = `${ows}?SERVICE=WFS&VERSION=1.0.0&REQUEST=GetFeature&typeName=${landUrl}&SRS=EPSG%3A4490&outputFormat=application%2Fjson`;
|
|
|
- var cql = `&cql_filter=INTERSECTS(${geoField},${wktString}) and (${query})`;
|
|
|
- geoServerUrl += cql;
|
|
|
- GetApi.getData(geoServerUrl).then((data) => {
|
|
|
- console.log(data);
|
|
|
- if (data.features.length < 1) {
|
|
|
+ axios.post(url, xml, {
|
|
|
+ headers: {
|
|
|
+ 'Content-Type': 'text/xml'
|
|
|
+ },
|
|
|
+ transformRequest: [(data) => data]
|
|
|
+ })
|
|
|
+ .then(res => {
|
|
|
+ const data = res.data;
|
|
|
+ if (!data.features || data.features.length < 1) {
|
|
|
message.info('未叠加到符合条件的供地数据');
|
|
|
- if (markersLayers) {
|
|
|
- markersLayers.clearLayers();
|
|
|
- }
|
|
|
+ if (markersLayers) markersLayers.clearLayers();
|
|
|
form.value.formItem.ycdj = '';
|
|
|
return;
|
|
|
}
|
|
|
- var attrs = [];
|
|
|
|
|
|
+ // 调用 algorithm 进行后续处理
|
|
|
+ var attrs = [];
|
|
|
var origGeo = arcgisToGeoJSON(geo);
|
|
|
var center = turf.center(origGeo);
|
|
|
let pt = center.geometry.coordinates;
|
|
|
var orign = { geojson: origGeo, center: pt };
|
|
|
+
|
|
|
data.features.forEach((item) => {
|
|
|
var geojson = item.geometry;
|
|
|
if (geojson.geometries) {
|
|
|
geojson.geometries.forEach((it) => {
|
|
|
- var origGeo = arcgisToGeoJSON(geo);
|
|
|
- var center = turf.center(it);
|
|
|
- let pt = center.geometry.coordinates;
|
|
|
try {
|
|
|
var interGeo = turf.intersect(origGeo, it);
|
|
|
if (interGeo) {
|
|
|
var area = turf.area(turf.getGeom(interGeo)).toFixed(2);
|
|
|
- console.log(area);
|
|
|
- attrs.push({ area: area, attributes: item.properties, geo: interGeo, center: pt });
|
|
|
+ attrs.push({
|
|
|
+ area: area,
|
|
|
+ attributes: item.properties,
|
|
|
+ geo: interGeo,
|
|
|
+ center: turf.center(it).geometry.coordinates
|
|
|
+ });
|
|
|
}
|
|
|
} catch (e) {
|
|
|
- console.log(e);
|
|
|
+ console.error(e);
|
|
|
}
|
|
|
});
|
|
|
} else {
|
|
|
- var origGeo = arcgisToGeoJSON(geo);
|
|
|
- var center = turf.center(geojson);
|
|
|
- let pt = center.geometry.coordinates;
|
|
|
+ try {
|
|
|
var interGeo = turf.intersect(origGeo, geojson);
|
|
|
if (interGeo) {
|
|
|
var area = turf.area(turf.getGeom(interGeo)).toFixed(2);
|
|
|
- console.log(area);
|
|
|
- attrs.push({ area: area, attributes: item.properties, geo: interGeo, center: pt });
|
|
|
+ attrs.push({
|
|
|
+ area: area,
|
|
|
+ attributes: item.properties,
|
|
|
+ geo: interGeo,
|
|
|
+ center: turf.center(geojson).geometry.coordinates
|
|
|
+ });
|
|
|
+ }
|
|
|
+ } catch (e) {
|
|
|
+ console.error(e);
|
|
|
}
|
|
|
}
|
|
|
});
|
|
|
- //克里金差值
|
|
|
+
|
|
|
+ //克里金插值
|
|
|
algorithm(orign, attrs);
|
|
|
+ })
|
|
|
+ .catch(error => {
|
|
|
+ message.error('供地数据查询失败');
|
|
|
+ console.error(error);
|
|
|
});
|
|
|
};
|
|
|
const queryGDByGeoServerFeature1 = (geo) => {
|
|
@@ -2150,6 +2180,23 @@ const queryGDByGeoServerFeature1 = (geo) => {
|
|
|
var orign = { geojson: origGeo, center: pt };
|
|
|
data.features.forEach((item) => {
|
|
|
var geojson = item.geometry;
|
|
|
+ if (geojson.geometries) {
|
|
|
+ geojson.geometries.forEach((it) => {
|
|
|
+ var origGeo = arcgisToGeoJSON(geo);
|
|
|
+ var center = turf.center(it);
|
|
|
+ let pt = center.geometry.coordinates;
|
|
|
+ try {
|
|
|
+ var interGeo = turf.intersect(origGeo, it);
|
|
|
+ if (interGeo) {
|
|
|
+ var area = turf.area(turf.getGeom(interGeo)).toFixed(2);
|
|
|
+ console.log(area);
|
|
|
+ attrs.push({ area: area, attributes: item.properties, geo: interGeo, center: pt });
|
|
|
+ }
|
|
|
+ } catch (e) {
|
|
|
+ console.log(e);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ } else {
|
|
|
var origGeo = arcgisToGeoJSON(geo);
|
|
|
var center = turf.center(geojson);
|
|
|
let pt = center.geometry.coordinates;
|
|
@@ -2157,7 +2204,8 @@ const queryGDByGeoServerFeature1 = (geo) => {
|
|
|
if (interGeo) {
|
|
|
var area = turf.area(turf.getGeom(interGeo)).toFixed(2);
|
|
|
console.log(area);
|
|
|
- attrs.push({ area: area, attributes: item.properties, geo: geojson, center: pt });
|
|
|
+ attrs.push({ area: area, attributes: item.properties, geo: interGeo, center: pt });
|
|
|
+ }
|
|
|
}
|
|
|
});
|
|
|
//克里金差值
|
|
@@ -2497,14 +2545,12 @@ const handleAnalysisData = (data) => {
|
|
|
for (var i = 0; i < item.result.length; i++) {
|
|
|
var t = item.result[i];
|
|
|
if (t.unit == 'km') {
|
|
|
- if (t.distance < 3000) {
|
|
|
if (t.center && t.center.indexOf(',') > -1) {
|
|
|
zgdFlag = true;
|
|
|
var pt = [];
|
|
|
pt.push(t.center.split(',')[0]);
|
|
|
pt.push(t.center.split(',')[1]);
|
|
|
attrs.push({ attributes: t, center: pt });
|
|
|
- }
|
|
|
}
|
|
|
}
|
|
|
}
|