एक GML3 सामग्री-स्ट्रिंग से पढ़ना सुविधा
Nov 07 2020
मैं एक GML3 फ़ाइल से ज्यामितीय कैसे दिखा सकता हूं? कुछ भी नहीं दिखाया गया है।
यह प्रश्न मानचित्र पर शो GML से अलग है (उदाहरण GML फ़ाइल का उपयोग करके) ।
अन्य परियोजना को नक्शे पर दिखाई देने वाली एक अजीब GML2 फ़ाइल प्राप्त करना था।
अपने कोणीय प्रोजेक्ट में, मैंने सबसे पहले विशिष्ट प्रक्षेपण निर्धारित किया।
proj4.defs("EPSG:28992", "+proj=sterea +lat_0=52.15616055555555 +lon_0=5.38763888888889 +k=0.9999079 +x_0=155000 +y_0=463000 +ellps=bessel +towgs84=565.040,49.910,465.840,-0.40939,0.35971,-1.86849,4.0772 +units=m +no_defs");
register(proj4)
this.dutchProjection = GetProjection('EPSG:28992');
यह है कि मैंने GML फ़ाइल (त्रुटियों के बिना) कैसे पढ़ी:
this.gmlFeatures = new GML3().readFeatures(this.fileText, {
featureProjection: 'EPSG:28992', dataProjection: 'EPSG:28992' });
जवाब
1 tm1701 Nov 09 2020 at 22:19
सुविधाएँ लोड हो रही हैं: 'संपत्ति' फ़ोल्डर से इस मामले में:
this.defineProjection();
this.httpClient.get('assets/wfs113-epsg-28992.xml', {responseType: 'text'})
.subscribe(
data => {
console.log(data);
this.fileText = data;
var wfsFormat = new WFS({
gmlFormat: new GML3()
});
this.gmlFeatures = wfsFormat.readFeatures(this.fileText, {
featureProjection: 'EPSG:28992',
dataProjection: 'EPSG:28992'
});
this.addGmlFeatures();
},
error => {
console.log(error);
}
);
आपको पहले विशिष्ट प्रक्षेपण को परिभाषित करना होगा:
defineProjection() {
proj4.defs("EPSG:28992", "+proj=sterea +lat_0=52.15616055555555 +lon_0=5.38763888888889 +k=0.9999079 +x_0=155000 +y_0=463000 +ellps=bessel +towgs84=565.040,49.910,465.840,-0.40939,0.35971,-1.86849,4.0772 +units=m +no_defs");
register(proj4)
this.dutchProjection = GetProjection('EPSG:28992');
}
मानचित्र पर सुविधाओं का प्रदर्शन:
ngAfterViewInit() {
let polygonStyle = new Style({
fill: new Fill({
color: "rgba(255, 0, 0, 0.8)"
}),
stroke: new Stroke({
color: "#ffcc33",
width: 10
})
});
this.vectorSource = new VectorSource({
format: new WFS(),
features: []
});
this.vectorLayer = new Vector({
source: this.vectorSource,
style: [polygonStyle]
});
let scaleInfo = new ScaleLine({
units: 'degrees',
minWidth: 100
});
const mousePosition = new MousePosition({
coordinateFormat: createStringXY(2),
projection: 'EPSG:28992',
undefinedHTML: ' No coordinate active'
});
this.map = new Map({
layers: [
new Tile({
source: new XYZ({
url: 'https://geodata.nationaalgeoregister.nl/tiles/service/wmts/brtachtergrondkaart/EPSG:3857/{z}/{x}/{y}.png',
})
}),
this.vectorLayer
],
view: new View({
projection: this.dutchProjection,
center: [173063,441818],
zoom: 9
}),
target: "map"
});
this.map.addControl(scaleInfo);
this.map.addControl(mousePosition);
this.addGmlFeatures();
}
और सुविधाओं को जोड़ना:
addGmlFeatures() {
if (this.gmlFeatures.length > 0) {
this.vectorLayer.getSource().addFeatures(this.gmlFeatures);
//this.map.getView().fit( this.vectorSource.getExtent());
console.log( this.map.getView().getProjection());
}
}
उदाहरण फ़ाइल:
<?xml version='1.0' encoding="ISO-8859-1" ?>
<wfs:FeatureCollection
xmlns:ms="http://mapserver.gis.umn.edu/mapserver"
xmlns:gml="http://www.opengis.net/gml"
xmlns:wfs="http://www.opengis.net/wfs"
xmlns:ogc="http://www.opengis.net/ogc"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://mapserver.gis.umn.edu/mapserver http://atl-p0-app001.culture.fr:5522/cgi-bin/mapserv?SERVICE=WFS&VERSION=1.1.0&REQUEST=DescribeFeatureType&TYPENAME=MD_2775&OUTPUTFORMAT=text/xml;%20subtype=gml/3.1.1 http://www.opengis.net/wfs http://schemas.opengis.net/wfs/1.1.0/wfs.xsd">
<gml:boundedBy>
<gml:Envelope srsName="EPSG:28992">
<gml:lowerCorner>173063 441818</gml:lowerCorner>
<gml:upperCorner>173563 444318</gml:upperCorner>
</gml:Envelope>
</gml:boundedBy>
<gml:featureMember>
<ms:MD_2775>
<gml:boundedBy>
<gml:Envelope srsName="EPSG:28992">
<gml:lowerCorner>173063 441818</gml:lowerCorner>
<gml:upperCorner>173563 444318</gml:upperCorner>
</gml:Envelope>
</gml:boundedBy>
<ms:msGeometry>
<gml:Polygon srsName="EPSG:28992">
<gml:exterior>
<gml:LinearRing>
<gml:posList srsDimension="2">173063 441818 173463 441818 173463 444818 173063 444818 173063 441818 </gml:posList>
</gml:LinearRing>
</gml:exterior>
</gml:Polygon>
</ms:msGeometry>
<ms:CODE></ms:CODE>
<ms:LIBELLE></ms:LIBELLE>
<ms:D_CREAT>19890303</ms:D_CREAT>
<ms:ZONE>ZPPAUP</ms:ZONE>
<ms:SURFACE>4.62397681219e+006</ms:SURFACE>
<ms:COORD_X>6.70482028142e+005</ms:COORD_X>
<ms:COORD_Y>7.09856001803e+006</ms:COORD_Y>
<ms:INSEE>59309</ms:INSEE>
<ms:COMMUNE>HONDSCHOOTE</ms:COMMUNE>
<ms:DEPARTEMEN>NORD</ms:DEPARTEMEN>
<ms:REGION>NORD-PAS-DE-CALAIS</ms:REGION>
</ms:MD_2775>
</gml:featureMember>
</wfs:FeatureCollection>