KML文件渲染问题 - 流畅的文本

时间:2015-03-18 12:44:59

标签: kml cesium

我们有KML文件,其中包含一些非常严格定义的折线(主要用于绘制文本,但不仅仅是)。当我们将相同的KML文件引入Cesium(1.6或1.7),OpenLayers或GoogleEarth时,我得到相同的结果:

  1. Cesium以非常锯齿状的方式呈现文本。
  2. OpenLayers& GoogleEarth可以平滑地呈现文本。
  3. Cesium Jagged Text Cesium Jagged Close-Up Open Layers Text Open Layers Text Close-Up

    我们已经查看了我们认为负责“细化”数据的removeDuplicates()方法。如果我们将EPSILON设置为更高的值,则可以很好地呈现“文本折线”。我们可以在某处覆盖removeDuplicatesEpsilon变量吗?

    removeDuplicates()方法中,一旦确定我们至少有1个要删除的点,就会将每个后续点与列表中的上一个点进行比较。它不应该将每个点与之前接受的点进行比较吗? (而不是列表中的前一个点,也可能不包括在内)。

    铯代码:

    var removeDuplicatesEpsilon = CesiumMath.EPSILON7;
    
    PolylinePipeline.removeDuplicates = function(positions) {
        if (!defined(positions)) {
               throw new DeveloperError('positions is required.');
        }
    
         var length = positions.length;
         if (length < 2) {
              return undefined;
         }
    
         var i;
         var v0;
         var v1;
    
         for (i = 1; i < length; ++i) {
              v0 = positions[i - 1];
              v1 = positions[i];
              if (Cartesian3.equalsEpsilon(v0, v1, removeDuplicatesEpsilon)) {
                   break;
              }
         }
    
         if (i === length) {
              return undefined;
         }
    
         var cleanedPositions = positions.slice(0, i);
         for (; i < length; ++i) {
              v0 = positions[i - 1];
              v1 = positions[i];
              if (!Cartesian3.equalsEpsilon(v0, v1, removeDuplicatesEpsilon)) {
                   cleanedPositions.push(Cartesian3.clone(v1));
              }
         }
    
         return cleanedPositions;
    };
    

    示例KML -

    <?xml version="1.0" encoding="utf-16"?>
    <kml xmlns="http://www.opengis.net/kml/2.2">
    <Document>
    <Document id="c7e47ca6-242c-4e1a-b4ca-02aff9d98ee4">
        <name>Letters</name>
        <Placemark id="c00e3314-bc14-4a1e-aa66-d3d70e217cda1">
            <name>C</name>
            <styleUrl>#S0</styleUrl>
            <LineString>
                <coordinates>-93.7997582661072,28.2156338033321,0 -93.7997341817777,28.2156233335357,0 -93.7997105791612,28.2156025354265,0 -93.7996990187067,28.215581878842,0 -93.7997036750268,28.2155796151045,0 -93.7997150749106,28.2155995642938,0 -93.7997375535976,28.215619372004,0 -93.7997595506083,28.2156291343859,0 -93.7998041869331,28.2156291344279,0 -93.7998263445402,28.2156193720874,0 -93.7998486627121,28.2155995644193,0 -93.799860223207,28.2155798982196,0 -93.7998713020103,28.2155500452192,0 -93.799871302029,28.2154999600916,0 -93.7998602232594,28.215470107084,0 -93.7998486627993,28.2154504408918,0 -93.79982634469,28.2154306331999,0 -93.7998041871417,28.2154208708285,0 -93.799759550904,28.2154208707865,0 -93.7997375539044,28.2154306331165,0 -93.7997150751844,28.2154504407663,0 -93.799703675239,28.215470389905,0 -93.7996990189326,28.2154681261704,0 -93.7997105794524,28.2154474696035,0 -93.7997341821035,28.2154266715762,0 -93.7997582664183,28.2154164848056,0 -93.7998056322006,28.21541648485,0 -93.7998295559378,28.2154266716658,0 -93.7998533191013,28.2154474697376,0 -93.7998647189985,28.2154684092942,0 -93.7998766005805,28.2154993941569,0 -93.7998766005639,28.2155506111568,0 -93.7998647189493,28.2155815960297,0 -93.7998533190173,28.2156025355605,0 -93.7998295557876,28.2156233336253,0 -93.7998056319859,28.2156338033766,0 -93.7997582661072,28.2156338033321,0 </coordinates>
            </LineString>
        </Placemark>
        <Placemark id="c00e3314-bc14-4a1e-aa66-d3d70e217cda2">
            <name>O - outer</name>
            <styleUrl>#S0</styleUrl>
            <LineString>
                <coordinates>-93.7995333556067,28.2156193715947,0 -93.7995556738038,28.2155995639742,0 -93.7995672343623,28.2155798977991,0 -93.7995783132305,28.2155500448223,0 -93.7995783133866,28.2154999596947,0 -93.7995672347159,28.2154701066634,0 -93.7995556743001,28.2154504404467,0 -93.7995333562743,28.2154306327072,0 -93.7995111987138,28.2154208702886,0 -93.7994665624956,28.2154208701515,0 -93.7994445654692,28.2154306324346,0 -93.7994220866754,28.2154504400365,0 -93.7994106866767,28.2154701061829,0 -93.7993994471974,28.2154999591456,0 -93.7993994469574,28.2155500442731,0 -93.7994106861621,28.2155798973185,0 -93.7994220859925,28.215599563564,0 -93.7994445646446,28.2156193713221,0 -93.7994665616286,28.2156291337509,0 -93.7995111979339,28.215629133888,0 -93.7995333556067,28.2156193715947,0 </coordinates>
            </LineString>
        </Placemark>
        <Placemark id="c00e3314-bc14-4a1e-aa66-d3d70e217cda3">
            <name>O - inner</name>
            <styleUrl>#S0</styleUrl>
            <LineString>
                <coordinates>-93.7994652771049,28.2156338026944,0 -93.7994411928333,28.2156233328466,0 -93.7994175902544,28.2156025346871,0 -93.7994060298579,28.21558159511,0 -93.7993941484081,28.2155506101895,0 -93.7993941486561,28.2154993931896,0 -93.7994060303933,28.2154684083745,0 -93.7994175909711,28.2154474688642,0 -93.7994411936987,28.2154266708872,0 -93.7994652780122,28.2154164841678,0 -93.7995126438043,28.2154164843132,0 -93.7995365675037,28.21542667118,0 -93.7995603306005,28.2154474693023,0 -93.7995717304402,28.2154684088833,0 -93.7995836119713,28.2154993937713,0 -93.7995836118142,28.2155506107712,0 -93.7995717300805,28.2155815956187,0 -93.7995603300911,28.2156025351253,0 -93.7995365668139,28.2156233331395,0 -93.7995126429933,28.2156338028398,0 -93.7994652771049,28.2156338026944,0 </coordinates>
            </LineString>
        </Placemark>
        <Placemark id="c00e3314-bc14-4a1e-aa66-d3d70e217cda4">
            <name>N</name>
            <styleUrl>#S0</styleUrl>
            <LineString>
                <coordinates>-93.7993079697249,28.215631538367,0 -93.7991525469176,28.2154261036618,0 -93.7991525454582,28.2156315375975,0 -93.7991472468299,28.2156315375682,0 -93.7991472483541,28.2154184635286,0 -93.7991528680389,28.2154184635597,0 -93.7993084514863,28.2156238982652,0 -93.7993084526457,28.2154184643294,0 -93.7993135906132,28.2154184643519,0 -93.799313589421,28.2156315383915,0 -93.7993079697249,28.215631538367,0 </coordinates>
            </LineString>
        </Placemark>
        <Placemark id="c00e3314-bc14-4a1e-aa66-d3d70e217cda5">
            <name>D - outer</name>
            <styleUrl>#S0</styleUrl>
            <LineString>
                <coordinates>-93.7990499914568,28.2154208681741,0 -93.7989722794574,28.2154208676656,0 -93.7989387219477,28.2154306297883,0 -93.7989167247776,28.215450437311,0 -93.7989051640743,28.2154701034143,0 -93.7988940850263,28.2154999563369,0 -93.7988940845493,28.2155500414644,0 -93.7989051630401,28.2155798945499,0 -93.798916723389,28.2155995608385,0 -93.7989387202291,28.2156193686758,0 -93.7989722776264,28.2156291312649,0 -93.7990499897774,28.2156291317735,0 -93.7990499914568,28.2154208681741,0 </coordinates>
            </LineString>
        </Placemark>
        <Placemark id="c00e3314-bc14-4a1e-aa66-d3d70e217cda6">
            <name>D - inner</name>
            <styleUrl>#S0</styleUrl>
            <LineString>
                <coordinates>-93.7989716353721,28.2156338002082,0 -93.7989361511849,28.2156233301936,0 -93.7989120670252,28.2156025319439,0 -93.7989006673004,28.2155815923255,0 -93.7988887859973,28.2155506073613,0 -93.7988887864877,28.2154993903614,0 -93.7989006683714,28.21546840559,0 -93.7989120684759,28.215447466121,0 -93.7989361529804,28.2154266682341,0 -93.798971637284,28.2154164816816,0 -93.7990551294986,28.2154164822266,0 -93.7990551277566,28.2156338007532,0 -93.7989716353721,28.2156338002082,0 </coordinates>
            </LineString>
        </Placemark>
        <Placemark id="c00e3314-bc14-4a1e-aa66-d3d70e217cda7">
            <name>S</name>
            <styleUrl>#S0</styleUrl>
            <LineString>
                <coordinates>-93.798701722344,28.2156337980995,0 -93.7986662382611,28.2156233280153,0 -93.7986424752182,28.2156028126893,0 -93.7986464893054,28.215599275651,0 -93.7986688072375,28.2156193665025,0 -93.7987023646879,28.2156291291575,0 -93.7987476432453,28.215629129548,0 -93.7987812009125,28.2156193674718,0 -93.7988030375251,28.2156001259057,0 -93.7988030377204,28.2155813086054,0 -93.7987917986145,28.2155619252865,0 -93.7987808804753,28.2155524458179,0 -93.7987585624292,28.2155422588161,0 -93.7986895208716,28.2155220260795,0 -93.7986657578042,28.2155118390668,0 -93.7986537158051,28.2155010862216,0 -93.7986418344649,28.2154800050847,0 -93.798641834845,28.2154480298286,0 -93.7986662405537,28.2154266660558,0 -93.7987017248053,28.2154164795729,0 -93.7987484483853,28.2154164799759,0 -93.7987839324884,28.2154266670708,0 -93.7988075349079,28.2154471823538,0 -93.7988036813654,28.2154507194153,0 -93.7987812029095,28.2154306285844,0 -93.7987476455143,28.2154208659486,0 -93.7987023670453,28.2154208655581,0 -93.7986688094332,28.215430627615,0 -93.7986471333646,28.2154498691614,0 -93.798647133023,28.2154787317685,0 -93.7986582115585,28.2154982565818,0 -93.7986691296813,28.2155077360687,0 -93.7986914477116,28.2155179230851,0 -93.7987604891892,28.2155381558207,0 -93.7987842522715,28.215548342817,0 -93.7987964549006,28.2155590956521,0 -93.7988081757464,28.2155801767744,0 -93.7988081755213,28.2156019652309,0 -93.7987839304126,28.2156233290302,0 -93.7987484460192,28.2156337985024,0 -93.798701722344,28.2156337980995,0 </coordinates>
            </LineString>
        </Placemark>
    </Document>
    <Style id="S0">
        <LineStyle>
            <color>ff007fff</color>
        </LineStyle>
        <PolyStyle>
            <color>ff004080</color>
        </PolyStyle>
    </Style>
    </Document>
    </kml>
    

1 个答案:

答案 0 :(得分:2)

这似乎是Cesium中的一个错误。我已经打开pull request #2609来修复它。