You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The issue is, d3-geo package is filling the whole earth instead the area, when one of my geo Polygon is small.
Following is the picture of testing case.
The case can be repeated by the html code.
<!DOCTYPE html><htmllang="en"><head><metacharset="UTF-8" /><titleD3-GeoDebug></title><scriptsrc="https://d3js.org/d3.v6.min.js"></script></head><body><div><h1>D3-Geo Debug</h1><p>It shows a strange behavior of D3-Geo</p><p>If the features of geoJson is of too small and other unknown characters,</p><p>D3 will parse it to filling the whole earth.</p></div><divstyle="display:flex;"><divid="Div-1"><h2>Incorrect Plot of Both Area</h2><p>It supposes to be TWO SMALL Areas</p><p>However, one area is shown as the whole earth,</p><p>and, the black point is the other area</p><p>
coordinates: [
[
[
[112.902145, 29.79149],
[112.929246, 29.77383],
[112.923703, 29.766557],
[112.894138, 29.783699],
[112.902145, 29.79149],
],
],
[
[
[112.716747, 32.357612],
[112.735841, 32.356095],
[112.733993, 32.356601],
[112.724138, 32.358623],
[112.716747, 32.357612],
],
],
],
</p></div><divid="Div-2" style="padding-left:20px;"><h2>Correct Plot of One Area</h2><p>The zoom-in view of the black point</p><p>
coordinates: [
[
[
[112.902145, 29.79149],
[112.929246, 29.77383],
[112.923703, 29.766557],
[112.894138, 29.783699],
[112.902145, 29.79149],
],
],
],
</p></div></div><scripttype="text/javascript">letgeoJson1={type: "FeatureCollection",name: "100000_full",features: [{type: "Feature",properties: {adcode: "xx",name: "xx",center: [114.298572,30.584355],centroid: [112.271286,30.987521],childrenNum: 0,level: "xx",parent: {adcode: 0},subFeatureIndex: 0,acroutes: [0],},geometry: {type: "MultiPolygon",coordinates: [[[[112.902145,29.79149],[112.929246,29.77383],[112.923703,29.766557],[112.894138,29.783699],[112.902145,29.79149],],],[[[112.716747,32.357612],[112.735841,32.356095],[112.733993,32.356601],[112.724138,32.358623],[112.716747,32.357612],],],],},},]}letgeoJson2={type: "FeatureCollection",name: "100000_full",features: [{type: "Feature",properties: {adcode: "xx",name: "xx",center: [114.298572,30.584355],centroid: [112.271286,30.987521],childrenNum: 0,level: "xx",parent: {adcode: 0},subFeatureIndex: 0,acroutes: [0],},geometry: {type: "MultiPolygon",coordinates: [[[[112.902145,29.79149],[112.929246,29.77383],[112.923703,29.766557],[112.894138,29.783699],[112.902145,29.79149],],],],},},]}</script><scripttype="text/javascript">console.log('You are using D3.js version of',d3.version)letwidth=500;letheight=500;letsvg1=d3.select("#Div-1").append("svg").attr("width",width).attr("height",height);letsvg2=d3.select("#Div-2").append("svg").attr("width",width).attr("height",height);functiondraw(svg,json){letfeatures=json.featuresletprojection=d3.geoNaturalEarth1().fitSize([width,height],json).rotate([0,0,0]).precision(20);letpath=d3.geoPath(projection);svg.selectAll("path").data(features).enter().append("path").attr("d",path).style("fill",function(d){console.log(d);leth=parseInt(Math.random()*360),s=0.5,l=0.5;returnd3.hsl(h,s,l).toString();}).style("stroke-width",3).style("stroke","#000000")}draw(svg1,geoJson1)draw(svg2,geoJson2)</script></body></html>
The text was updated successfully, but these errors were encountered:
The issue is, d3-geo package is filling the whole earth instead the area, when one of my geo Polygon is small.
Following is the picture of testing case.
The case can be repeated by the html code.
The text was updated successfully, but these errors were encountered: