问题:我正在尝试找到一种方法来修复一些破碎的多边形形状,但不确定如何做到这一点。
详细资料:
我有很多多边形,基本上是从TIGERLINES不久前导入的。
我将它们转换为形状文件,然后将其导入Sql Server 2008。
在sql server 2008中,它们看起来很棒:)因此,这表明导入或多或少都起作用。这是洛杉矶市:-
但是,由于我的多边形有很多点,REDUCE
因此在地图视图级别未放大时会显示它们。因此,以我为例,我现在尝试渲染缩小的洛杉矶:-
太棒了!
这是polys,是众所周知的文本格式。
MULTIPOLYGON (((-118.37033296865027 33.981437119998084, -118.37005887887605 33.981578692036159, -118.37034101004039 33.981636093563019, -118.37033296865027 33.981437119998084)), ((-118.66815694082851 34.181234948814819, -118.62915309690062 34.14689902389253, -118.56475201393673 34.130168028388276, -118.5992039806748 34.074336925351339, -118.57039497030522 34.069345957209549, -118.56968692628638 33.988811006799452, -118.55134001501617 33.982488918901176, -118.49446792996977 34.050559988837591, -118.44342601159182 34.016625025023124, -118.53748592914029 33.96667393391462, -118.49898897162241 33.916299091437473, -118.43732802504242 33.91651401198633, -118.4580839734636 33.961275936767734, -118.42944687485486 33.916317947202252, -118.4287748805515 33.93096998019935, -118.36821587274666 33.92901995236047, -118.37033296865027 33.981437119998084, -118.38014006025271 33.976370879899918, -118.40620312831412 33.9894040312244, -118.40276798429554 34.003464906235209, -118.44721596021705 33.990835906868767, -118.36957705476188 34.035079980519519, -118.37898513570399 34.01930701338695, -118.35780514530173 33.997145063915781, -118.33148511073327 34.001491938133285, -118.37005887887605 33.981578692036159, -118.3177468750705 33.970922985911365, -118.31338700532739 33.93821409504941, -118.29159591706274 33.959494911587832, -118.29062400107088 33.866332991682327, -118.30914811626086 33.865608026065182, -118.30099998201904 33.757721074150069, -118.33305692619008 33.721861951611757, -118.29415704014427 33.704554033590789, -118.23180307928671 33.71500194765504, -118.24896594980441 33.755902076278147, -118.22066886552763 33.782536959833138, -118.22662214917852 33.829531051866013, -118.23026099256474 33.792772095531092, -118.2565120484562 33.804774040894074, -118.2991459834285 33.797795976339046, -118.29920702986115 33.846318895031622, -118.28155507034047 33.86280202135606, -118.28208595952513 33.923201066885447, -118.23032405030229 33.929000895691168, -118.23399502457268 33.953263926662473, -118.25364008888438 33.943276983800338, -118.25643608790811 33.989497954281944, -118.23791790420275 33.989393059909709, -118.23970793049459 34.014713121327667, -118.19142810960136 34.012760956499392, -118.19262502907846 34.061762066095284, -118.1648349431549 34.062282928139695, -118.15528996126079 34.098672108789643, -118.17799390878898 34.098595067874996, -118.16558689825808 34.125466989766352, -118.18258002511257 34.129185991443848, -118.18392009154192 34.148673011439996, -118.22623088187513 34.149788973944844, -118.25425797615566 34.11876096748162, -118.28169102368197 34.156473098182232, -118.30964606995528 34.1612589323332, -118.34566505636386 34.142366926730304, -118.37031291768209 34.196379107293332, -118.33992999453659 34.206502959021506, -118.33746198396433 34.221312054601036, -118.26687107795063 34.221846086487439, -118.26667204057179 34.250779088440183, -118.2387889442851 34.281588919772553, -118.28669401126965 34.278336948162604, -118.29939493959903 34.293259048809304, -118.35470798399948 34.278848025464875, -118.3857618914668 34.284817020858974, -118.38739588298223 34.298779939448842, -118.4061680961638 34.2859269071303, -118.40520195114632 34.329811005464386, -118.50380990538876 34.337305995327178, -118.54629607559784 34.317332026288142, -118.5408208870528 34.2988139356695, -118.58853302357504 34.303219086876425, -118.59620799129411 34.274520945225589, -118.63346111715893 34.269525030054467, -118.63072510622223 34.2377719451453, -118.65873494162602 34.224578011901244, -118.66815694082851 34.181234948814819), (-118.46636404681055 34.0590670662609, -118.45468090186466 34.066799004274742, -118.44817495570614 34.049578023438457, -118.46636404681055 34.0590670662609), (-118.42624590643248 34.083052060665487, -118.39585612350398 34.112414074702421, -118.39584401878872 34.091055026539784, -118.34338194827956 34.09432806847537, -118.37695090866218 34.088630040183155, -118.3702939050842 34.0801689603087, -118.39070402303155 34.072083071358719, -118.37224405760227 34.062199935390908, -118.40602306576152 34.052665897923667, -118.42624590643248 34.083052060665487), (-118.45592304445982 34.284612059955819, -118.43256891423674 34.304687007226292, -118.41566704665274 34.2939320092269, -118.4437338970905 34.273310001969548, -118.45592304445982 34.284612059955819), (-118.3623419482557 34.1386959352159, -118.34569798267972 34.14235601789391, -118.34877496666293 34.131385983468121, -118.3623419482557 34.1386959352159), (-118.46233312716733 33.979751022958048, -118.43225893050703 33.9750159246595, -118.4513010127346 33.964230958845896, -118.46233312716733 33.979751022958048)))
现在,要在Google地图上显示多边形,我需要从Sql Server中提取数据,将其转换为Google Maps格式,然后进行显示。这对..说.. 95%的多边形非常有用。其他5%的样子..非常非常混乱。
洛杉矶不行:-
所以我猜你会建议-> 检查代码中是否有错误?我们可以看到代码吗?它与代码有关系!
好吧,这是我在Codeplex中建立的示例代码库。它包括带有形状的二进制数据的单元测试。(SELECT MediumReducedBoundary.STAsBinary() FROM Table WHERE Id=1
)
然后,我将Parse
这个byte[]
..并显示在Google Map上。
我的转换代码返回两个多边形,而不是一个。
这就是我的Json的样子。.注意现在它有两个多边形吗?
该客户端的JavaScript代码可以在这里找到。这是我解码json并尝试将其手动呈现到Google地图上的地方。
我希望可能有一种方法/程序可以读取我的json结果并告诉我此数据是否错误(我将其错误地转换了)。或者,如果有人可以看到我将WKT错误地转换为Google格式的JSON的地方?
REDUCE
,并通过了有效/简单的测试。但是,我不知道如何验证json。
POINT (-118.37024428585559 33.981550635199085)
,这很有趣,但我认为这不是问题的原因。