cochs
cochs

Reputation: 1

Polygons in d3.js not filling/building correctly

I have been tasked with drawing up a set of features that are given to me in a wkt format that translates to EPSG 4326 coordinates, changing those to EPSG 3857 then with the new coordinates producing a rough map of the features for the sake of displaying information directly related to them.

I have accomplished all of the tasks save one, correctly drawing the polygons for lots, (we have data for poles overhead lines and land parcels)I can only provide the coordinates for some of these. I am using proj4js for the translation from 4326 to 3857 and wellknown.js to parse from wkt to the 4326 coordinates. The drawing of lots is being done by d3, and the click events are taken care of with a mix of jquery and d3.

I feel it is also worth mentioning this is all housed in a standalone application that uses cefsharp as it's window for viewing the map(so no server side script is possible, nor is a command line).

The following is data I am originally passed.

{
"Information" : {
    "ALLE31113" : [{
            "PK_UID" : "7129",
            "geoText" : "MULTIPOLYGON(((-9035602.307487 4363592.799839, -9035646.762385 4363669.887824, -9035684.243076 4363735.247325, -9035735.642396 4363822.429784, -9035770.281248 4363805.006812, -9035824.253019 4363751.636147, -9035848.197629 4363727.726674, -9035907.876876 4363697.629949, -9035963.84742 4363668.909586, -9036035.632131 4363644.776346, -9036072.4994 4363631.941562, -9036069.614947 4363716.726557, -9036066.914278 4363816.281436, -9036063.645231 4363922.511598, -9036058.844839 4364080.084017, -9036080.477324 4364071.671115, -9036123.477431 4364031.843033, -9036147.132026 4364076.760663, -9036178.631235 4364136.90146, -9036175.954358 4364137.843585, -9036106.35999 4364162.548467, -9036069.892896 4364176.634671, -9036038.196664 4364190.140612, -9036002.855712 4364199.448907, -9035989.071442 4364203.007609, -9035964.978261 4364209.268322, -9035955.739394 4364210.944745, -9035942.912073 4364213.175299, -9035936.588774 4364214.003407, -9035928.837657 4364214.458878, -9035919.484521 4364215.234717, -9035905.42119 4364214.854484, -9035881.672012 4364210.837086, -9035875.909829 4364209.181291, -9035843.076827 4364200.919313, -9035813.092942 4364188.934902, -9035799.466957 4364182.556206, -9035779.956569 4364171.078452, -9035769.421706 4364165.392331, -9035747.008816 4364155.360576, -9035741.503088 4364152.43956, -9035739.678464 4364151.410204, -9035733.959049 4364147.186818, -9035727.911312 4364143.279579, -9035721.687107 4364139.780211, -9035715.273573 4364136.641466, -9035708.679112 4364133.886925, -9035701.95548 4364131.539215, -9035695.051436 4364129.599461, -9035688.061579 4364128.065585, -9035680.986426 4364126.961341, -9035673.826406 4364126.306522, -9035666.718617 4364126.058512, -9035659.580799 4364126.242881, -9035652.448771 4364126.874687, -9035645.372827 4364127.909255, -9035638.401386 4364129.397016, -9035631.485856 4364131.279623, -9035624.721094 4364133.566878, -9035618.107014 4364136.254822, -9035611.644133 4364139.367209, -9035605.378715 4364142.855496, -9035599.310762 4364146.719684, -9035593.581055 4364150.905193, -9035588.048468 4364155.450768, -9035582.806825 4364160.318705, -9035577.855697 4364165.489209, -9035573.194566 4364170.938528, -9035570.71162 4364174.272532, -9035572.745391 4364167.692613, -9035572.769281 4364167.521775, -9035576.541778 4364155.120969, -9035576.641661 4364154.817758, -9035576.842872 4364154.096442, -9035576.961153 4364153.55122, -9035578.90989 4364143.424318, -9035578.945346 4364143.241344, -9035579.047583 4364142.502396, -9035579.106289 4364141.756481, -9035579.113753 4364141.011691, -9035579.074003 4364140.271897, -9035578.982838 4364139.52531, -9035578.853633 4364138.84293, -9035576.752294 4364129.078184, -9035576.735408 4364129.027064, -9035576.554101 4364128.30622, -9035576.321724 4364127.594418, -9035576.046418 4364126.903361, -9035575.724157 4364126.229177, -9035575.359054 4364125.579698, -9035574.951108 4364124.954924, -9035574.50829 4364124.35864, -9035574.326006 4364124.136875, -9035573.925274 4364123.662451, -9035568.476226 4364117.179381, -9035568.172936 4364116.833526, -9035567.652662 4364116.302313, -9035567.27825 4364115.950097, -9035554.546094 4364104.782772, -9035554.497847 4364104.740262, -9035549.047539 4364100.01184, -9035532.511797 4364085.668233, -9035519.732259 4364070.323343, -9035519.449025 4364069.992891, -9035509.717742 4364059.175624, -9035488.494372 4364035.270599, -9035463.099069 4364006.478426, -9035452.467619 4363994.338225, -9035441.0728 4363978.46396, -9035432.688554 4363962.301902, -9035427.205855 4363950.452832, -9035422.673747 4363937.161038, -9035420.655056 4363925.92917, -9035419.992171 4363914.299244, -9035421.825928 4363894.5229, -9035422.491258 4363887.394915, -9035425.854654 4363855.62383, -9035425.867065 4363855.469092, -9035426.640162 4363847.130762, -9035428.971753 4363821.774924, -9035428.984422 4363821.632062, -9035430.835066 4363798.461226, -9035430.844568 4363798.35408, -9035431.622369 4363787.148176, -9035433.692936 4363772.282025, -9035440.533759 4363745.199665, -9035443.741284 4363735.108928, -9035458.78938 4363704.808894, -9035472.569432 4363682.030209, -9035490.34558 4363662.221509, -9035508.662079 4363647.680447, -9035529.379567 4363635.292766, -9035529.465248 4363635.243359, -9035529.597538 4363635.161246, -9035565.282953 4363612.745705, -9035601.098715 4363591.07182, -9035602.307487 4363592.799839)))"
        }, {
            "PK_UID" : "10731",
            "geoText" : "MULTIPOLYGON(((-9035929.47332 4364305.899606, -9035929.439854 4364304.36304, -9035931.822393 4364282.400836, -9035937.324703 4364245.381886, -9035937.381852 4364244.938999, -9035937.438355 4364244.194856, -9035937.448509 4364243.834941, -9035937.532661 4364236.789521, -9035938.69263 4364236.723933, -9035946.337261 4364235.724201, -9035959.730148 4364233.386152, -9035969.534573 4364231.602237, -9035987.757719 4364227.423179, -9035995.417038 4364224.925904, -9036008.734251 4364221.468551, -9036041.938135 4364211.99331, -9036038.918068 4364275.373389, -9036037.006664 4364315.792182, -9036046.529107 4364374.544171, -9036055.247877 4364425.186392, -9036065.913757 4364452.06818, -9036011.765211 4364456.161688, -9035991.463304 4364419.244796, -9035929.47332 4364305.899606)))"
        }, {
            "PK_UID" : "10736",
            "geoText" : "MULTIPOLYGON(((-9035939.490439 4364668.621934, -9035937.719485 4364587.312244, -9035962.167318 4364605.328638, -9035965.040116 4364607.445521, -9035965.655177 4364607.867958, -9035966.294704 4364608.24802, -9035966.957458 4364608.585486, -9035967.640933 4364608.878432, -9035968.34191 4364609.126184, -9035969.057641 4364609.327072, -9035969.784666 4364609.480675, -9035970.520254 4364609.586063, -9035971.261192 4364609.642812, -9035972.004275 4364609.650992, -9035972.746291 4364609.610178, -9035973.484048 4364609.520937, -9035974.214343 4364609.383338, -9035974.933984 4364609.197947, -9035975.640283 4364608.965812, -9035976.3298 4364608.687505, -9035976.999865 4364608.364817, -9035977.647289 4364607.998562, -9035978.269654 4364607.590771, -9035978.864033 4364607.142996, -9035979.428003 4364606.657023, -9035979.958895 4364606.134889, -9035980.455045 4364605.579357, -9035980.91378 4364604.992216, -9035981.333188 4364604.376232, -9035981.7116 4364603.733918, -9035982.0476 4364603.068274, -9035982.339274 4364602.38182, -9035982.58595 4364601.677788, -9035982.646751 4364601.459095, -9035982.785964 4364600.958937, -9035982.938899 4364600.228743, -9035983.043829 4364599.489949, -9035983.100331 4364598.745782, -9035983.108475 4364597.99946, -9035983.067838 4364597.254211, -9035983.045295 4364597.022743, -9035976.637689 4364537.517335, -9035974.239459 4364464.967544, -9035944.545164 4364400.954582, -9035943.543993 4364396.271061, -9035936.013734 4364365.589273, -9036002.009654 4364481.919921, -9036025.487639 4364549.301946, -9036022.832157 4364625.081615, -9036034.594618 4364661.018348, -9036001.341587 4364663.955437, -9035960.939992 4364666.962361, -9035939.490439 4364668.621934)))"
        }, {
            "PK_UID" : "10772",
            "geoText" : "MULTIPOLYGON(((-9035879.828201 4364518.715458, -9035879.085124 4364518.707271, -9035878.343113 4364518.748078, -9035877.605362 4364518.837312, -9035876.875071 4364518.974903, -9035876.155435 4364519.160287, -9035875.44914 4364519.392413, -9035874.759625 4364519.670712, -9035874.089563 4364519.993391, -9035873.44214 4364520.359638, -9035872.819777 4364520.767419, -9035872.225398 4364521.215185, -9035871.661428 4364521.701149, -9035871.130534 4364522.223273, -9035870.634383 4364522.778797, -9035870.175645 4364523.365929, -9035869.756234 4364523.981904, -9035869.377819 4364524.62421, -9035869.041814 4364525.289845, -9035868.750136 4364525.976292, -9035868.503454 4364526.680317, -9035868.303433 4364527.399161, -9035868.291599 4364527.455616, -9035866.620392 4364533.554758, -9035861.492323 4364552.267889, -9035855.352443 4364547.321863, -9035833.5118 4364529.728089, -9035831.796261 4364528.346022, -9035786.402792 4364462.704517, -9035785.278657 4364461.065624, -9035741.201845 4364397.367943, -9035739.834495 4364395.425446, -9035702.751581 4364341.936043, -9035665.719102 4364288.754616, -9035653.506778 4364271.222652, -9035592.904275 4364182.887567, -9035594.657271 4364180.805338, -9035598.686992 4364176.605624, -9035602.907655 4364172.663134, -9035607.414376 4364168.999544, -9035612.119921 4364165.593002, -9035616.973565 4364162.468387, -9035622.023642 4364159.672167, -9035627.269119 4364157.156833, -9035632.663729 4364154.970932, -9035638.112355 4364153.092784, -9035643.710631 4364151.56782, -9035649.363958 4364150.398116, -9035655.118602 4364149.535127, -9035660.833609 4364149.025514, -9035666.651142 4364148.878041, -9035672.428522 4364149.06019, -9035678.166354 4364149.599675, -9035683.911939 4364150.495458, -9035689.570159 4364151.725861, -9035693.903449 4364152.961576, -9035695.141532 4364153.314637, -9035700.625025 4364155.214282, -9035705.977278 4364157.425746, -9035711.143626 4364159.973995, -9035716.222095 4364162.833112, -9035721.022449 4364165.959745, -9035725.687623 4364169.398286, -9035728.525914 4364171.522338, -9035737.617964 4364176.146995, -9035773.322997 4364194.612598, -9035789.97951 4364203.249783, -9035802.937099 4364209.358002, -9035820.082509 4364216.538723, -9035850.451327 4364226.637267, -9035870.144034 4364231.266665, -9035876.282762 4364233.009255, -9035910.275158 4364237.823545, -9035914.803939 4364238.220643, -9035914.749503 4364242.783215, -9035909.328163 4364279.25674, -9035909.270584 4364279.702609, -9035908.075743 4364290.718683, -9035907.479952 4364305.044753, -9035906.735775 4364327.372536, -9035920.371997 4364401.390608, -9035949.843482 4364468.216806, -9035953.933438 4364538.289521, -9035953.9356 4364538.434048, -9035953.976235 4364539.179294, -9035953.998777 4364539.41076, -9035957.695509 4364573.74209, -9035940.312734 4364560.932376, -9035892.192119 4364525.443308, -9035886.054224 4364520.91663, -9035885.434156 4364520.490341, -9035884.794638 4364520.110277, -9035884.131892 4364519.772809, -9035883.448424 4364519.47986, -9035882.747455 4364519.232104, -9035882.031731 4364519.031213, -9035881.304713 4364518.877605, -9035880.569132 4364518.772212, -9035879.828201 4364518.715458)))"
        }, {
            "PK_UID" : "12671",
            "geoText" : "MULTIPOLYGON(((-9036619.517705 4364930.696288, -9036521.80966 4364925.198309, -9036448.099483 4364921.045953, -9036378.159821 4364917.124525, -9036323.459799 4364914.027155, -9036323.418489 4364913.997861, -9036321.298982 4364912.475922, -9036272.404829 4364877.664621, -9036230.873044 4364848.228794, -9036211.702935 4364802.330222, -9036182.484464 4364732.387733, -9036150.202183 4364656.119983, -9036120.634327 4364584.950128, -9036087.596459 4364506.727296, -9036065.913757 4364452.06818, -9036055.247877 4364425.186392, -9036046.529107 4364374.544171, -9036037.006664 4364315.792182, -9036038.918068 4364275.373389, -9036041.938135 4364211.99331, -9036078.22052 4364198.291455, -9036079.348489 4364197.933951, -9036127.383064 4364182.618996, -9036166.974355 4364186.121121, -9036205.480936 4364198.293397, -9036290.173108 4364195.360855, -9036297.500865 4364242.753141, -9036315.214218 4364353.868966, -9036328.186678 4364440.901013, -9036342.207623 4364536.937596, -9036412.136044 4364585.825091, -9036476.781539 4364538.106403, -9036503.587223 4364514.808149, -9036514.679407 4364505.164614, -9036560.509839 4364464.728309, -9036672.380036 4364933.678954, -9036666.633636 4364933.355264, -9036619.517705 4364930.696288)))"
        }
    ]
}

}

The changes I make end up forming the following (proj4js, wkt parse) another sidenote I have found that I have to multiply the coordinates I receive from the proj4js reprojection(EPSG:3857) by 3600 to make them not stack upon each other or even look remotely correct.

{
"type" : "FeatureCollection",
"features" : [{
        "type" : "Feature",
        "geometry" : {
            "type" : "MultiPolygon",
            "coordinates" : [[[[-292205.5075454828, 131242.7381194875], [-292206.9451879985, 131244.74323762624], [-292208.1572891916, 131246.44327754018], [-292209.8195098026, 131248.71092959752], [-292210.9397077689, 131248.25775231433], [-292212.68511977367, 131246.8695590297], [-292213.4594729026, 131246.24766141336], [-292215.3894609727, 131245.46482823993], [-292217.1995119976, 131244.71779298913], [-292219.5209829076, 131244.0900702342], [-292220.7132464318, 131243.75622778927], [-292220.619965096, 131245.9615422812], [-292220.5326272154, 131248.5510091098], [-292220.42690835946, 131251.31407654067], [-292220.27166680136, 131255.4125158191], [-292220.97124731017, 131255.19369879115], [-292222.36184283026, 131254.15778013683], [-292223.1268170625, 131255.3260764106], [-292224.1454810142, 131256.89031577852], [-292224.0589125514, 131256.91482002346], [-292221.80827591073, 131257.55738205774], [-292220.6289537861, 131257.9237567501], [-292219.6039182385, 131258.2750386581], [-292218.4610148144, 131258.51714190378], [-292218.01524047926, 131258.60970158185], [-292217.23608266073, 131258.77253885075], [-292216.9373037051, 131258.8161415589], [-292216.52247647877, 131258.8741568554], [-292216.3179850978, 131258.89569541687], [-292216.06731901056, 131258.9075419266], [-292215.7648446697, 131258.9277210023], [-292215.31004568306, 131258.91783138557], [-292214.5420126981, 131258.81334141621], [-292214.355667444, 131258.77027522898], [-292213.2938694933, 131258.55538627467], [-292212.324210135, 131258.24367883895], [-292211.88355463394, 131258.07777259013], [-292211.2526013633, 131257.77924249932], [-292210.91191073915, 131257.63134949026], [-292210.1870924398, 131257.37042864124], [-292210.00904077373, 131257.29445445383], [-292209.9500336192, 131257.26768140635], [-292209.76507145434, 131257.1578331696], [-292209.5694915695, 131257.05620772563], [-292209.3682048241, 131256.96519078268], [-292209.1607953019, 131256.88355345186], [-292208.947534718, 131256.81190907277], [-292208.73009682796, 131256.75084617146], [-292208.506824531, 131256.70039401567], [-292208.28077709745, 131256.66049856326], [-292208.05197124666, 131256.6317776501], [-292207.8204208523, 131256.61474608714], [-292207.5905595744, 131256.60829545258], [-292207.3597271783, 131256.61309081182], [-292207.12908202695, 131256.62952381655], [-292206.90025059576, 131256.65643248713], [-292206.67479872366, 131256.69512850896], [-292206.45115497697, 131256.74409429726], [-292206.23238696944, 131256.80358479227], [-292206.0184919199, 131256.8734970155], [-292205.8094865477, 131256.95444878974], [-292205.60686700064, 131257.0451775245], [-292205.41063334345, 131257.1456832365], [-292205.2253383421, 131257.2545463156], [-292205.0464180734, 131257.37277449045], [-292204.87690674467, 131257.49938708715], [-292204.7167904823, 131257.63386923666], [-292204.5660525344, 131257.7756031508], [-292204.4857556741, 131257.86231880155], [-292204.5515265067, 131257.69117862164], [-292204.5522990938, 131257.68673521507], [-292204.6742991956, 131257.36419658197], [-292204.67752934684, 131257.35631021403], [-292204.68403637985, 131257.3375491411], [-292204.6878615106, 131257.32336818532], [-292204.7508823989, 131257.05997231943], [-292204.75202902284, 131257.05521325118], [-292204.7553353011, 131257.03599355786], [-292204.75723381486, 131257.01659265484], [-292204.75747519586, 131256.9972210112], [-292204.7561897067, 131256.9779793099], [-292204.7532414898, 131256.95856092442], [-292204.7490630841, 131256.94081253235], [-292204.68110714626, 131256.6868358266], [-292204.680561064, 131256.68550621753], [-292204.6746977133, 131256.66675737605], [-292204.6671827921, 131256.64824371185], [-292204.65827957506, 131256.63026961507], [-292204.6478578637, 131256.61273437663], [-292204.6360506698, 131256.59584170365], [-292204.6228579613, 131256.57959159632], [-292204.608537515, 131256.5640825009], [-292204.6026425689, 131256.55831448652], [-292204.5896831563, 131256.54597491748], [-292204.4134644846, 131256.377352934], [-292204.4036562831, 131256.3683573849], [-292204.38683095993, 131256.35454074838], [-292204.3747227192, 131256.34537975144], [-292203.96297306713, 131256.05492195048], [-292203.9614127905, 131256.05381628123], [-292203.7851533713, 131255.93083176357], [-292203.25039821945, 131255.55775948794], [-292202.83711626433, 131255.1586436345], [-292202.8279566608, 131255.15004867365], [-292202.5132532917, 131254.86869454567], [-292201.8269032963, 131254.24693043984], [-292201.0056356983, 131253.49805091985], [-292200.6618215133, 131253.1822857557], [-292200.2933204709, 131252.76939749834], [-292200.0221794031, 131252.34902314263], [-292199.84487248, 131252.04082899634], [-292199.6983070521, 131251.69510921396], [-292199.6330238968, 131251.40296780725], [-292199.61158662674, 131251.10047257136], [-292199.67088913656, 131250.58608764797], [-292199.69240547635, 131250.400687727], [-292199.8011755176, 131249.57431571296], [-292199.80157688126, 131249.57029094192], [-292199.8265783359, 131249.3534089711], [-292199.90198047383, 131248.6938964849], [-292199.9023901811, 131248.69018059966], [-292199.96223880554, 131248.08749926038], [-292199.96254609403, 131248.08471235336], [-292199.98769967305, 131247.7932425025], [-292200.0546604644, 131247.40656775702], [-292200.2758882352, 131246.70214297855], [-292200.37961750955, 131246.4396777619], [-292200.8662631564, 131245.65155693874], [-292201.3119010842, 131245.0590691428], [-292201.88677016005, 131244.5438314859], [-292202.47911383625, 131244.1656080436], [-292203.14910393645, 131243.84339517998], [-292203.15187480435, 131243.84211006612], [-292203.15615297697, 131243.8399742442], [-292204.3101961107, 131243.25692827674], [-292205.4684545817, 131242.69317221118], [-292205.5075454828, 131242.7381194875]]]]
        },
        "properties" : {
            "parent" : "ALLE31113",
        }
    }, {
        "type" : "Feature",
        "geometry" : {
            "type" : "MultiPolygon",
            "coordinates" : [[[[-292216.0878759389, 131261.2858466722], [-292216.0867936702, 131261.24588191055], [-292216.1638434334, 131260.67466322548], [-292216.3417845635, 131259.7118284369], [-292216.343632725, 131259.7003092621], [-292216.3454599954, 131259.68095463273], [-292216.3457883691, 131259.67159349946], [-292216.3485097901, 131259.4883470708], [-292216.3860224339, 131259.48664117238], [-292216.63324483315, 131259.46063883495], [-292217.06636209646, 131259.39982778902], [-292217.38343083026, 131259.35342937833], [-292217.972755531, 131259.24473490388], [-292218.22045293066, 131259.17978244857], [-292218.6511229459, 131259.0898589805], [-292219.72491497954, 131258.8434140718], [-292219.6272479751, 131260.49188491888], [-292219.56543441175, 131261.54314393894], [-292219.87338403094, 131263.0712270023], [-292220.1553433875, 131264.38837604062], [-292220.5002710163, 131265.08753955737], [-292218.74914222286, 131265.19400670603], [-292218.09259174217, 131264.23384191855], [-292216.0878759389, 131261.2858466722]]]]
        },
        "properties" : {
            "parent" : "ALLE31113",
        }
    }, {
        "type" : "Feature",
        "geometry" : {
            "type" : "MultiPolygon",
            "coordinates" : [[[[-292216.4118230585, 131270.7197827349], [-292216.35455155687, 131268.60505116012], [-292217.14517859055, 131269.07362937764], [-292217.23808301124, 131269.1286861405], [-292217.2579736844, 131269.13967305428], [-292217.278655572, 131269.1495578614], [-292217.3000886057, 131269.15833481416], [-292217.32219174306, 131269.1659538724], [-292217.34486088384, 131269.17239750663], [-292217.36800715927, 131269.1776222829], [-292217.3915186753, 131269.18161725174], [-292217.4153071133, 131269.18435822535], [-292217.4392685668, 131269.1858341762], [-292217.4632993882, 131269.1860469249], [-292217.4872957035, 131269.184985418], [-292217.51115428546, 131269.1826644021], [-292217.53477155126, 131269.17908567176], [-292217.5580442736, 131269.17426394776], [-292217.58088552434, 131269.16822648686], [-292217.60318405606, 131269.16098816565], [-292217.62485352275, 131269.15259556522], [-292217.6457907943, 131269.14306985628], [-292217.66591767396, 131269.1324638618], [-292217.68513950467, 131269.12081794668], [-292217.703377928, 131269.1081785618], [-292217.72054663027, 131269.09459868624], [-292217.7365917989, 131269.080150181], [-292217.7514269908, 131269.06487957505], [-292217.76499037293, 131269.0488588075], [-292217.7772279712, 131269.0321532374], [-292217.7880939928, 131269.01484088995], [-292217.7975265405, 131268.99698730616], [-292217.80550388206, 131268.97867654517], [-292217.8074701468, 131268.97298868527], [-292217.81197220477, 131268.9599803642], [-292217.81691802334, 131268.94098916836], [-292217.8203113913, 131268.92177429877], [-292217.8221386293, 131268.90241968454], [-292217.82240200095, 131268.8830090208], [-292217.82108782686, 131268.86362626278], [-292217.8203588008, 131268.85760614273], [-292217.6131409863, 131267.30995940013], [-292217.53558378643, 131265.42303613905], [-292216.5752895806, 131263.75813381706], [-292216.542912361, 131263.6363205202], [-292216.2993886779, 131262.83831920705], [-292218.4336538484, 131265.86394598742], [-292219.192916628, 131267.61646020383], [-292219.1070400656, 131269.58737249768], [-292219.4874304114, 131270.5220266227], [-292218.4120489957, 131270.59841524088], [-292217.10548766516, 131270.67662012536], [-292216.4118230585, 131270.7197827349]]]]
        },
        "properties" : {
            "parent" : "ALLE31113",
        }
    }, {
        "type" : "Feature",
        "geometry" : {
            "type" : "MultiPolygon",
            "coordinates" : [[[[-292214.4823850484, 131266.8209488911], [-292214.45835442113, 131266.82073595852], [-292214.43435826746, 131266.8217972924], [-292214.4104998795, 131266.82411814592], [-292214.3868827431, 131266.8276966983], [-292214.3636101824, 131266.83251828083], [-292214.34076906106, 131266.83855555818], [-292214.31847059407, 131266.84579373154], [-292214.2968012243, 131266.8541861672], [-292214.2758639852, 131266.8637117462], [-292214.25573717017, 131266.87431756686], [-292214.2365153395, 131266.8859633416], [-292214.2182769162, 131266.89860259302], [-292214.20110814914, 131266.91218231537], [-292214.1850629482, 131266.92663072472], [-292214.17022765934, 131266.9419012136], [-292214.15666418016, 131266.95792186802], [-292214.14442648494, 131266.97462735412], [-292214.1335603015, 131266.99193959407], [-292214.1241276245, 131267.00979312407], [-292214.11615008896, 131267.02810383207], [-292214.10968153976, 131267.04679996043], [-292214.1092988359, 131267.04826827615], [-292214.0552530874, 131267.20689838892], [-292213.889414668, 131267.6936000677], [-292213.69085493835, 131267.5649611129], [-292212.98454273515, 131267.10737211606], [-292212.9290633186, 131267.07142649055], [-292211.4610680265, 131265.36417762117], [-292211.4247142311, 131265.3215520447], [-292209.99929877085, 131263.664849235], [-292209.95507956034, 131263.61432698634], [-292208.75584221707, 131262.22312180136], [-292207.5582359088, 131260.83991988623], [-292207.16329728585, 131260.38392749496], [-292205.20345171663, 131258.08639110334], [-292205.2601424682, 131258.03223349366], [-292205.39046102704, 131257.9230012535], [-292205.52695452597, 131257.82045922856], [-292205.6726989547, 131257.72517120745], [-292205.82487322256, 131257.63656883856], [-292205.98183691566, 131257.55529921805], [-292206.14515312447, 131257.48257096176], [-292206.3147884423, 131257.4171483908], [-292206.48924662446, 131257.36029419393], [-292206.6654516489, 131257.3114444901], [-292206.8464962571, 131257.27178092182], [-292207.02932117897, 131257.24135748862], [-292207.21542262676, 131257.2189115616], [-292207.40024223964, 131257.20565677277], [-292207.5883774768, 131257.2018210709], [-292207.77521419205, 131257.20655867882], [-292207.9607719506, 131257.22059042394], [-292208.1465804362, 131257.24388930693], [-292208.32956359437, 131257.2758914912], [-292208.46969937737, 131257.3080318344], [-292208.5097381771, 131257.31721477778], [-292208.68707077776, 131257.36662360688], [-292208.860159162, 131257.4241426833], [-292209.02723549947, 131257.490421355], [-292209.191469887, 131257.5647855279], [-292209.34671021625, 131257.64610763278], [-292209.49757891207, 131257.7355422757], [-292209.5893673988, 131257.79078773677], [-292209.88339838805, 131257.9110725641], [-292211.0380759551, 131258.3913523943], [-292211.5767367626, 131258.6160003794], [-292211.99577677145, 131258.77487137134], [-292212.55024819024, 131258.96163736016], [-292213.53235603153, 131259.22429385912], [-292214.16920538014, 131259.34470137893], [-292214.3677278549, 131259.39002495614], [-292215.4670198542, 131259.51524131675], [-292215.6134776891, 131259.5255695592], [-292215.6117172642, 131259.64423885205], [-292215.43639465125, 131260.59288780423], [-292215.43453258387, 131260.60448450164], [-292215.3958922022, 131260.89100365495], [-292215.3766247085, 131261.26361268075], [-292215.3525585078, 131261.84433853684], [-292215.7935450669, 131263.76947437727], [-292216.746633742, 131265.5075453811], [-292216.8789002615, 131267.3300428591], [-292216.8789701792, 131267.3338018005], [-292216.8802842887, 131267.35318458674], [-292216.88101328234, 131267.3592046872], [-292217.00056319317, 131268.2521121686], [-292216.4384155445, 131267.91895065122], [-292214.8822261229, 131266.99593095298], [-292214.6837305867, 131266.87819833876], [-292214.66367799055, 131266.86711115076], [-292214.64299639396, 131266.8572262108], [-292214.62156361894, 131266.84844913371], [-292214.5994607079, 131266.84082993414], [-292214.57679182594, 131266.834386142], [-292214.5536457768, 131266.82916124386], [-292214.5301344871, 131266.82516611138], [-292214.50634627556, 131266.8224249845], [-292214.4823850484, 131266.8209488911]]]]
        },
        "properties" : {
            "parent" : "ALLE31113",
        }
    }, {
        "type" : "Feature",
        "geometry" : {
            "type" : "MultiPolygon",
            "coordinates" : [[[[-292238.40346297843, 131277.53579746513], [-292235.2436482911, 131277.39280805283], [-292232.85990906175, 131277.28481505916], [-292230.5981058374, 131277.18282792016], [-292228.8291426685, 131277.10227256943], [-292228.82780672994, 131277.10151070083], [-292228.7592632508, 131277.06192861777], [-292227.17805811274, 131276.15656635223], [-292225.83494717197, 131275.39100557088], [-292225.2149983032, 131274.19728099927], [-292224.2700919364, 131272.37821529177], [-292223.226103945, 131270.39462855252], [-292222.26989869424, 131268.54361616066], [-292221.2014755102, 131266.5091531268], [-292220.5002710163, 131265.08753955737], [-292220.1553433875, 131264.38837604062], [-292219.87338403094, 131263.0712270023], [-292219.56543441175, 131261.54314393894], [-292219.6272479751, 131260.49188491888], [-292219.72491497954, 131258.8434140718], [-292220.89826373523, 131258.4870372735], [-292220.93474151974, 131258.47773880884], [-292222.4881484637, 131258.07940572267], [-292223.7685050893, 131258.17049401038], [-292225.0137828984, 131258.48708778375], [-292227.75267271034, 131258.41081411584], [-292227.9896476103, 131259.6434566486], [-292228.5624859367, 131262.53348564092], [-292228.982006864, 131264.79709496212], [-292229.4354351148, 131267.29488121285], [-292231.6968748124, 131268.56637260245], [-292233.787468116, 131267.32528022063], [-292234.654346519, 131266.71932514446], [-292235.0130605421, 131266.4685098708], [-292236.4951869337, 131265.41681393477], [-292240.1129964146, 131277.61336951298], [-292239.92716157244, 131277.6049511071], [-292238.40346297843, 131277.53579746513]]]]
        },
        "properties" : {
            "parent" : "ALLE31113",
        }
    }
]
}

I am unsure if this problem is caused from d3 reading the coordinates incorrectly, proj4js translating them wrong or something I have done on my side. I have used the shoelace formula to test for CW listing of the polygons and they seem to check out as such (I could be mistaken) but this is the only set of information I have gotten that has behaved this particular way. If any additional information is needed and I can provide it I will, (including snippets of my code and currently working sets of points that go through the same process as the ones above).

The main issue is that though it will draw the bounds correctly it draws the polygon as a hole inside of a much larger square (not a simple bounding box) and fills the outer area.

The code below is the snippet I use following the shoelace formula to determine if the order of polygon vertices is CW or CCW. Vertices is the list of coordinates found in the JSON.

function polygonArea(vertices) {
var sum = 0.0;
for (var i = 0; i < vertices.length; i++) {
    var v1 = vertices[i];
    var v2 = vertices[(i + 1) % vertices.length];
    sum += (v2[0] - v1[0]) * (v2[1] + v1[1]);
}
return sum > 0.0;
}

Thank you for your time.

Upvotes: 0

Views: 916

Answers (1)

cochs
cochs

Reputation: 1

So to fix the problem I was having I utilized d3 to draw the paths then extracted the points along the path (as that is the only way to get the properly projected points that d3 generates) with pathSegList and injected those into an array that could be pushed into an svg polygon element.

d3.select(this).selectAll('path').each(function(){
    var coords = [];
    var pArr = this.pathSegList;
    for(var i = 0; i < pArr.length; i++){
        if (pArr[i].x && pArr[i].y){
            coords[i] = [pArr[i].x, pArr[i].y]
        }
    }
    d3.select(this.parentNode).append('polygon')
        .attr('points', coords)
    d3.select(this).attr('fill', 'rgba(0,0,0,0)')
    this.remove();
});

The first this is a reference to a g element that houses the paths in my svg, the second this (the one that is removed is a reference to the path that I retrieve the coordinates from.

It seems that the svg polygon doesn't care which order points are in if that was the problem, and extrapolates what is the interior on it's own, this may be limited however and I am testing that.

Upvotes: 0

Related Questions