区分圆与多边形

时间:2015-10-27 14:40:10

标签: javascript serialization kml

我正在编写一个javascript序列化器/反序列化器,用于将描述形状的简单JSON对象转换为kml地标。

我不确定确定多边形是圆形还是多边形的最佳方法。或者,如果形状是多边形或矩形。

以下是圆圈的kml地标示例:

<Placemark id="1445955066458">
    <name>Circle</name>
    <description />
    <Style>
        <LineStyle>
            <color>FF22F0F0</color>
            <width>2</width>
        </LineStyle>
        <PolyStyle>
            <color>00FFFFFF</color>
        </PolyStyle>
    </Style>
    <Polygon>
        <tessellate>true</tessellate>
        <altitudeMode>clampToGround</altitudeMode>
        <outerBoundaryIs>
        <LinearRing>
            <altitudeMode>clampToGround</altitudeMode>
            <coordinates>
                -85.9436441792769,42.7633718619449 -86.1049817775046,42.782250840711 -86.2603356151588,42.8195439351303 -86.4058803651668,42.8743328654495 -86.538032232748,42.94526854637 -86.6535372003356,43.0306043060057 -86.7495511522886,43.128238894741 -86.823709906458,43.2357682249708 -86.8741874281972,43.3505445677153 -86.8997407933959,43.4697417484954 -86.8997407933959,43.5904247371276 -86.8741874281972,43.7096219179077 -86.823709906458,43.8243982606522 -86.7495511522886,43.931927590882 -86.6535372003356,44.0295621796174 -86.538032232748,44.114897939253 -86.4058803651668,44.1858336201735 -86.2603356151588,44.2406225504927 -86.1049817775046,44.277915644912 -85.9436441792769,44.2967946236781 -85.7802954875931,44.2967946236781 -85.6189578893654,44.277915644912 -85.4636040517112,44.2406225504927 -85.3180593017032,44.1858336201735 -85.185907434122,44.114897939253 -85.0704024665344,44.0295621796174 -84.9743885145813,43.931927590882 -84.900229760412,43.8243982606522 -84.8497522386728,43.7096219179077 -84.8241988734741,43.5904247371276 -84.8241988734741,43.4697417484954 -84.8497522386728,43.3505445677153 -84.900229760412,43.2357682249708 -84.9743885145813,43.128238894741 -85.0704024665344,43.0306043060057 -85.185907434122,42.94526854637 -85.3180593017032,42.8743328654495 -85.4636040517112,42.8195439351303 -85.6189578893654,42.782250840711 -85.7802954875931,42.7633718619449 -85.9436441792769,42.7633718619449 
            </coordinates>
        </LinearRing>
        </outerBoundaryIs>
    </Polygon>
    <Guid>106c9aab-135f-444e-b49b-764e2c8e5918</Guid>
</Placemark>`

对于多边形:

<Placemark id="1445955076821">
        <name>polygon</name>
        <description />
        <Style>
            <LineStyle>
                <color>FF22F0F0</color>
                <width>2</width>
            </LineStyle>
            <PolyStyle>
                <color>00FFFFFF</color>
            </PolyStyle>
        </Style>
        <Polygon>
            <tessellate>true</tessellate>
            <altitudeMode>clampToGround</altitudeMode>
            <outerBoundaryIs>
            <LinearRing>
            <altitudeMode>clampToGround</altitudeMode>
                <coordinates>-82.48916709906,41.569023672499 -83.950348739685,38.635674063124 -79.402008895935,39.580498281874 -82.48916709906,41.569023672499 </coordinates>
            </LinearRing>
            </outerBoundaryIs>
        </Polygon>
        <Guid>319fb6e0-1637-4740-bf66-5ae301e06c7a</Guid>
    </Placemark>

我知道圆圈有一定数量的点,(我认为是42),但也可能有一个多边形也有这个点数。

我考虑过将extendedData用于地标,但之后我无法使用其他来源的kml。

有什么想法吗?

0 个答案:

没有答案