Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
addFeatures(sFeaturesArr);
}
}, function () {});
} else {
var newFeautures = [],
features = layerInfo.features;
for (var i = 0, len = features.length; i < len; i++) {
var feature = features[i];
var sqlResult = jsonsql({
attr: feature.attributes
}, sql);
if (sqlResult.length > 0) {
var lon = feature.geometry.points[0].x,
lat = feature.geometry.points[0].y;
var point = new Point(lon, lat);
var vector = new Vector(point, feature.attributes, feature.style);
newFeautures.push(vector);
}
}
addFeatures(newFeautures);
}
} else if (isRestData) {
var dataSourceName = layerInfo.datasourceName;
subLayers = layerInfo.subLayers && JSON.parse(layerInfo.subLayers);
if (subLayers.length && subLayers.length > 0) {
subLayer = subLayers[0];
} else {
subLayer = subLayers;
}
layerName = subLayer && subLayer.name;
this.getFeaturesBySQL(layerInfo.url, dataSourceName, layerName, themeSettings.filter, DataFormat.ISERVER, (getFeaturesEventArgs) => {
var features, feature, result = getFeaturesEventArgs.result,
//压盖处理 -end
//将标签像素范围转为地理范围
var geoBs = [];
for (let j = 0; j < quadlen - 1; j++) {
geoBs.push(map.getCoordinateFromPixel([boundsQuad[j].x, boundsQuad[j].y]));
}
//屏蔽有偏移性质的style属性,偏移量在算bounds时已经加入计算
var bounds = new Bounds(geoBs[3][0], geoBs[3][1], geoBs[1][0], [geoBs[1][1]]);
var center = bounds.getCenterLonLat();
var label = new GeoText(center.lon, center.lat, fi.attributes[this.themeField]);
label.calculateBounds();
styTmp = CommonUtil.cloneObject(fi.style);
feaSty = CommonUtil.cloneObject(CommonUtil.copyAttributes(styTmp, styleTemp));
fea = new FeatureVector(label, fi.attributes, feaSty);
//赋予id
fea.id = fi.id;
fea.fid = fi.fid;
feas.push(fea);
}
}
//返回最终要绘制的标签要素
return feas;
}
//将标签像素范围转为地理范围
var geoBs = [];
for (let j = 0; j < quadlen - 1; j++) {
geoBs.push(map.unproject(boundsQuad[j]));
}
//屏蔽有偏移性质的style属性,偏移量在算bounds时已经加入计算
var leftBottom = geoBs[3];
var rightTop = geoBs[1];
var bounds = new Bounds(leftBottom.lng, leftBottom.lat, rightTop.lng, rightTop.lat);
var center = bounds.getCenterLonLat();
var label = new GeoText(center.lon, center.lat, fi.attributes[this.themeField]);
label.calculateBounds();
styTmp = Util.cloneObject(fi.style);
feaSty = Util.cloneObject(Util.copyAttributes(styTmp, styleTemp));
fea = new FeatureVector(label, fi.attributes, feaSty);
//赋予id
fea.id = fi.id;
fea.fid = fi.fid;
feas.push(fea);
}
}
//返回最终要绘制的标签要素
return feas;
}
var attrArr = this.getAttributesObjFromTable(rows, colTitles);
var features = [];
for (var i = 0, len = attrArr.length; i < len; i++) {
var lon = attrArr[i][position["lon"]];
var lat = attrArr[i][position["lat"]];
if (!lon || !lat) {
continue;
}
lon = parseFloat(lon);
lat = parseFloat(lat);
var geometry = new Point(lon, lat);
var pointGraphic;
if (isGraphic) {
pointGraphic = new Graphic(geometry, attrArr[i], null);
} else {
pointGraphic = new Vector(geometry, attrArr[i], null);
}
features.push(pointGraphic);
}
return features;
},
toiClientFeature(features) {
if (!Util.isArray(features)) {
features = [features];
}
let featuresTemp = [], geometry, attributes;
for (let i = 0, len = features.length; i < len; i++) {
if (features[i] instanceof ol.Feature) {
//热点图支支持传入点对象要素
if (features[i].getGeometry() instanceof ol.geom.Point) {
geometry = new GeometryPoint(features[i].getGeometry().getCoordinates()[0], features[i].getGeometry().getCoordinates()[1]);
//固定属性字段为 "Properties"
attributes = features[i].getProperties()["Properties"] ? features[i].getProperties()["Properties"] : {};
featuresTemp.push(new GeometryVector(geometry, attributes));
}
} else if (["FeatureCollection", "Feature", "Geometry"].indexOf(features[i].type) != -1) {
let format = new GeoJSONFormat();
featuresTemp = featuresTemp.concat(format.read(features[i]));
} else if (features[i].geometry && features[i].geometry.parts) {
//iServer服务器返回数据格式
featuresTemp.push(ServerFeature.fromJson(features[i]).toFeature());
} else {
throw new Error(`Features[${i}]'s type does not match, please check.`);
}
}
return featuresTemp;
}
toFeature() {
var geometry = Util.toSuperMapGeometry(this.geometry);
var points = [];
if (this.geometry instanceof mapboxgl.LngLat) {
points = [this.geometry.lng, this.geometry.lat];
} else if (this.geometry instanceof mapboxgl.Point) {
points = [this.geometry.x, this.geometry.y];
} else if (this.geometry.length === 3) {
geometry = new GeoText(this.geometry[0], this.geometry[1], this.geometry[2]);
}
if (points.length > 1) {
geometry = new Point(points[0], points[1]);
}
return new Vector(geometry, this.attributes);
}
}
geojsonObject.properties = this.attributes;
return new GeoJSON().read(geojsonObject)[0];
}
if (geometry.length === 3) {
geometry = new GeoText(geometry[1], geometry[0], geometry[2]);
} else if (geometry.length === 2) {
geometry = new GeometryPoint(points[0], points[1]);
} else if (geometry instanceof L.LatLng) {
geometry = new GeometryPoint(geometry.lng, geometry.lat);
} else if (geometry instanceof L.Point) {
geometry = new GeometryPoint(geometry.x, geometry.y);
} else if (geometry instanceof L.CircleMarker) {
var latLng = geometry.getLatLng();
geometry = new GeometryPoint(latLng.lng, latLng.lat);
}
return new Vector(geometry, this.attributes);
},
var points = [];
if (geometry instanceof L.LatLng) {
points = [geometry.lng, geometry.lat];
} else if (geometry instanceof L.Point) {
points = [geometry.x, geometry.y];
} else if (geometry instanceof L.CircleMarker) {
var latLng = geometry.getLatLng();
points = [latLng.lng, latLng.lat];
} else {
points = geometry;
}
if (points.length === 2) {
geometry = new GeometryPoint(points[0], points[1]);
}
return new Vector(geometry, this.attributes);
}