PolygonData Multiple Interior Rings

3 posts, 0 answers
  1. Michael
    Michael avatar
    18 posts
    Member since:
    Jul 2012

    Posted 26 Aug 2014 Link to this post

    I have a polygon that I'm mapping using PolygonData and the polygon has multiple interior rings in it. The outer ring opens and closes at the same point and all the interior rings the same. But when all the points are added to a PolygonData and that object added to a Visualization Layer the interior rings do not show up correctly. 
    Here's the code that creates the Polygon and adds it to the layer:

    var newPolygon = new PolygonData(){};
    foreach (var point in locations)
    {
         newPolygon.Points.Add(new Location(point .Latitude,
         point .Longitude));
    }
    Layer.Items.Add(newPolygon);

    And the data in the "locations" variable as WKT:

    POLYGON ((-114.19383099450356 47.663879150499071, -114.18843222500257 47.6638791505021, -114.18407467132894 47.663879170211686, -114.18844457499863 47.663860235997028, -114.18843677099585 47.660208114996841, -114.18301371299708 47.660259580999011, -114.18304228972342 47.663879150709334, -114.18303345549799 47.663879150500044, -114.18303345550481 47.667550185999943, -114.18303345550157 47.671165114022138, -114.17772366200229 47.671218273002218, -114.17236347100152 47.67118212600375, -114.16700330799755 47.671145703000889, -114.1670355039988 47.6747956870003, -114.16165525699935 47.674751762999, -114.15627500900067 47.674707839002089, -114.15090853999901 47.674696666002532, -114.13479260400219 47.674675870001, -114.13482541829066 47.685556842814478, -114.13480986200355 47.6855568850028, -114.13483633799729 47.689176732001847, -114.13752303039028 47.689166543515711, -114.13751726197243 47.6914363431781, -114.13482869649089 47.691436312139764, -114.13483022800158 47.690985085998285, -114.1294388420439 47.690973942998859, -114.12943984100117 47.689163644000246, -114.12676155600046 47.689157180042621, -114.12676155599741 47.685523301500247, -114.12406996200035 47.685523301498122, -114.12406996200286 47.68915062117663, -114.12404334399814 47.689150555999085, -114.12404250700104 47.685517374998383, -114.12404169799827 47.681884165003332, -114.11868123000366 47.681858214999352, -114.1133207620028 47.681831987002056, -114.11331217499789 47.678197498002554, -114.1133035860056 47.674563009999133, -114.10796648000141 47.674562699001704, -114.10796986500064 47.670941293003487, -114.11331577799822 47.670934355002906, -114.11332796899465 47.667305728001907, -114.11868093800088 47.667333791000466, -114.11868110899442 47.670964778997181, -114.12404649399876 47.670994924998958, -114.12941165899964 47.671022266003312, -114.13477682200166 47.671049605999777, -114.1401494859978 47.671054307002649, -114.14552220600305 47.671058729999807, -114.15088525899655 47.671068958997154, -114.15624831199663 47.671078938000072, -114.15622158700111 47.667450037002759, -114.16159636300363 47.6674729890002, -114.16155094300535 47.663838199998949, -114.15619464000339 47.663822108002378, -114.1561676920002 47.6601941240005, -114.16153960800139 47.660200326001529, -114.16156512949908 47.660200355688147, -114.1615651295015 47.663868657250568, -114.16156823725017 47.663868657322993, -114.16159591800592 47.667415598002215, -114.16694252600448 47.6674451340031, -114.16692750292955 47.6638686580685, -114.16696256699524 47.663868657251783, -114.16696256699763 47.66021293687804, -114.16691152299788 47.660212667998572, -114.16686543449615 47.660212492672393, -114.16686543450351 47.656599878249743, -114.172250060249 47.656599878254575, -114.1722500602461 47.652930822498121, -114.1722247891353 47.65293082308834, -114.17218707099958 47.649293503002148, -114.16683057299359 47.649292326997951, -114.166803598002 47.645653398998725, -114.1614522939999 47.645628193996615, -114.16147254600479 47.6492618719991, -114.15610974100352 47.649231111999455, -114.1507629100015 47.649224130000334, -114.1470748480056 47.64920747700193, -114.14541363399444 47.649216898999683, -114.14005785699848 47.6492057510011, -114.14005784737776 47.649203679660438, -114.14542313450056 47.649203679498527, -114.15079541325288 47.649203679503223, -114.15079541325126 47.645581857221011, -114.15074701800165 47.645581757003818, -114.14542313450231 47.645570854359192, -114.14539785300337 47.645570802001409, -114.14247620000064 47.645559478003115, -114.1400508557492 47.645551850473943, -114.14005085574637 47.647698767816017, -114.14004088200034 47.645551818999444, -114.13467857700171 47.645540198003182, -114.13467110099553 47.641903877997748, -114.12930571300059 47.641911646000722, -114.12930029299807 47.638288019998292, -114.12929676199902 47.6346643950022, -114.1292932320041 47.631031130002839, -114.12928831200306 47.627422310997105, -114.12928339099872 47.623803824000269, -114.1346429209959 47.623791030002117, -114.13463594599753 47.620169794000759, -114.13462897000298 47.616548586000512, -114.12927199600013 47.616545211003228, -114.1239150230012 47.616541835997424, -114.11855443700055 47.616587630002385, -114.11857016400418 47.620208201000374, -114.1185858900034 47.623828633000954, -114.1132479180061 47.623840649000606, -114.11324967200028 47.627458525000357, -114.11325139800037 47.631076374001033, -114.10791125999938 47.631074029001326, -114.10790872800149 47.627459541003276, -114.10256778300256 47.627460334001462, -114.09721236599756 47.627461267003447, -114.09721381499539 47.631070506001116, -114.09185623099943 47.63106893799997, -114.09185683308829 47.627485186025325, -114.09185683700255 47.627461921998339, -114.09185746965564 47.623862589760563, -114.091857470997 47.62385493199826, -114.09721091600083 47.623852083999608, -114.10256447300046 47.623848984003018, -114.10255788500162 47.620241884998691, -114.10788938500041 47.620239565000226, -114.10790619499858 47.623844941001551, -114.1132479180061 47.623840649000606, -114.11322088400226 47.620237021999294, -114.11319385199764 47.616633424001812, -114.10787260199967 47.616634076999027, -114.10255132400299 47.616634757003659, -114.09721001700224 47.616626076998905, -114.09186873899593 47.616617397004042, -114.09186177199736 47.620233914000032, -114.09186176478109 47.620239993412184, -114.08656298299759 47.620239993248866, -114.08656298300159 47.623862589500391, -114.08656298300552 47.627485185749684, -114.08656298299961 47.631085743239247, -114.08655360199937 47.631085773015421, -114.08132696399522 47.631102305003409, -114.07598632499595 47.631105043004382, -114.07064571499862 47.631107781998182, -114.06528640800136 47.631112881998817, -114.05992713000047 47.631118009003067, -114.05456590699642 47.631118720002341, -114.04920468400286 47.631119430999135, -114.04384193300258 47.631120280000616, -114.03847918200077 47.631121129001556, -114.03847869100103 47.634758262999874, -114.03847817200183 47.638395370001888, -114.04383572699759 47.638387102000756, -114.04384232000173 47.642008789996972, -114.04384893999506 47.645643119000205, -114.04922196699744 47.645642351002621, -114.04923133699916 47.6492628990021, -114.05459119699724 47.649253798004864, -114.0599515570018 47.649244445002736, -114.05995095399818 47.652866493998026, -114.06530295099739 47.652860086002562, -114.07065494999667 47.652853426998369, -114.0760000590041 47.652834964001322, -114.08134516800064 47.652816527001185, -114.08670035999926 47.652796951998852, -114.08669700319773 47.649195918725773, -114.09185624217362 47.649195916689884, -114.09185806899852 47.652778127999731, -114.09721926200336 47.652784970001122, -114.10258045499532 47.65279159100141, -114.10259646000213 47.656416245999651, -114.10795034699737 47.656425949997406, -114.10796704699938 47.660053854003571, -114.10797016199503 47.663683732001338, -114.10261533199952 47.663680946999008, -114.10261853000131 47.667319131001264, -114.09741590499385 47.667319762001426, -114.09733203300222 47.663677326998851, -114.09188191899931 47.663673820998568, -114.09187611800304 47.667322005998088, -114.09188890200245 47.670965857999839, -114.09733976600168 47.670955530002665, -114.10262389599424 47.670947980999017, -114.10262934600226 47.674562414003262, -114.10262523899996 47.67821018200101, -114.10262113299947 47.681857976999943, -114.10261702600074 47.685499606001677, -114.10261291799819 47.689141206002404, -114.10797638600184 47.689150322001396, -114.10798678000072 47.692757560004473, -114.10798416800029 47.691855757000937, -114.10530014200056 47.69184868600297, -114.10530197697409 47.692749644817027, -114.10261717299952 47.692741667000931, -114.09725604000278 47.692726246999179, -114.09725186799945 47.689132952003646, -114.09189084499683 47.689124670003281, -114.09723151875123 47.689132921034911, -114.09725186799945 47.689132952003646, -114.09993239300074 47.689137079002776, -114.1026009545018 47.6891411877223, -114.10260095450548 47.681860911999571, -114.0972416381716 47.681860912235486, -114.09725324200183 47.67822884399687, -114.09188182899959 47.678247228003492, -114.09186240495241 47.681823829395867, -114.09186220353936 47.681860912004318, -114.09188182899959 47.678247228003492, -114.09188222993005 47.67817340819343, -114.09190157499944 47.67461134799882, -114.08678948199838 47.674588007001354, -114.08659975574446 47.674587142885855, -114.08659975574571 47.678173407751338, -114.0865997557531 47.681823828503404, -114.08659975574911 47.681854016619525, -114.08145710999936 47.681825371998791, -114.07609939300141 47.681795670997339, -114.07607899599682 47.67816951300248, -114.07071800000605 47.678144340001815, -114.07069429800181 47.674522987000046, -114.0653329120008 47.674510286000746, -114.06534439100058 47.678130611000391, -114.06535584399957 47.681750799000731, -114.05997003999622 47.6817356540012, -114.05996840900365 47.685347758003651, -114.05996497100006 47.68895694400112, -114.0653616080012 47.688972894000493, -114.07075821599813 47.6889888420015, -114.07074683400009 47.692592555999767, -114.07607582599844 47.692610310001996, -114.07602857899779 47.696197662004806, -114.07755945100006 47.6961978770022, -114.0813504330023 47.696199610001322, -114.08661363800546 47.696252539819213, -114.08661363800232 47.696285688002042, -114.08132090899858 47.696285687999996, -114.0813209090001 47.699934111002953, -114.08661363799828 47.699934110999195, -114.08661363800029 47.703579083037475, -114.0869247290008 47.703580568999868, -114.0883996809968 47.703582534001775, -114.0919063669958 47.703579934003116, -114.09726135675223 47.703585124533973, -114.09726819400061 47.703585131002896, -114.10262999399834 47.703590328000821, -114.10263186849956 47.703590331516722, -114.10799154300054 47.703600248001628, -114.10800238025182 47.703600268297784, -114.11335306499792 47.703610166001113, -114.1187139539947 47.703619333794627, -114.11871466900047 47.703619335001868, -114.1240762739983 47.703628505004147, -114.12408808200136 47.703628526487016, -114.12899024099917 47.703637342999627, -114.12944182300213 47.70306285300358, -114.1294622099995 47.702831306518263, -114.12946220999733 47.701825223491156, -114.12848545799859 47.701068581999465, -114.12866012677459 47.700015662182473, -114.12866043999728 47.7000137739996, -114.12870302599804 47.69975707200075, -114.12943581999556 47.6992342219992, -114.12946220999562 47.699215392595505, -114.13011511099968 47.698749538002588, -114.1345249090022 47.69859284800097, -114.13481673199371 47.698464842997836, -114.13481184200376 47.696410232003295, -114.13482185014274 47.693454921463172, -114.13482075218127 47.69377915571075, -114.14019135074544 47.693779155503421, -114.14557085949831 47.693779155504444, -114.1455708594944 47.69275338126927, -114.14558311000218 47.692753334999615, -114.14558310927353 47.691436312034789, -114.15095036825105 47.691436311748333, -114.15095036824843 47.68911468432146, -114.15632987699823 47.689093468003669, -114.15631615719339 47.685497068031921, -114.16168167699497 47.68554687999913, -114.16167289900191 47.681977646997424, -114.1670433660011 47.682054403999913, -114.16704722899982 47.685596440998069, -114.17243019699657 47.6856391129979, -114.17243125300333 47.689147009997896, -114.17781144400125 47.689155514001094, -114.17846640100017 47.689155761003583, -114.18313645175266 47.689159429474948, -114.18318027300107 47.68915946300109, -114.18732552699802 47.689161806002915, -114.18851546150246 47.6891622875839, -114.18851546150123 47.68562838017494, -114.18852726899823 47.685628321000351, -114.18852706786481 47.685591451774613, -114.1938944712515 47.685591451502006, -114.193894471245 47.681963842998677, -114.18851546149782 47.68196384300407, -114.18851546149821 47.683463848970106, -114.1885079909967 47.682094314004452, -114.18848787900427 47.678401469999756, -114.18846773999856 47.674708626002243, -114.18843222499868 47.674709235827493, -114.18843222499885 47.67122122149938, -114.18843222500024 47.6675501860012, -114.19383099450076 47.667550186000263, -114.19383099450356 47.663879150499071)
     (-114.15629559481573 47.6801024529974, -114.15630245699994 47.681900640000038, -114.15630243916604 47.681900640032708, -114.15629558096885 47.680102453010811, -114.15629559481573 47.6801024529974)
     (-114.12408808200098 47.69639911760089, -114.124088081997 47.700015646251742, -114.11871395400296 47.700015646252474, -114.1133488558804 47.700015646461068, -114.11334883799951 47.700000372998815, -114.11871549999863 47.700007210001196, -114.12406804899972 47.70001379599961, -114.12405982300075 47.696399087003357, -114.12408808200098 47.69639911760089)
     (-114.10960403488322 47.699988818223076, -114.10800238024807 47.699988792002259, -114.10263186849758 47.699988791999886, -114.09726135675 47.699988792001434, -114.09190274217059 47.699988792278226, -114.09190269499557 47.69994205500285, -114.09726421700053 47.699954641001113, -114.10262571099582 47.699966978004916, -114.10799434500599 47.6999838139992, -114.10960403488322 47.699988818223076)
     (-114.09189493399755 47.692710546997446, -114.09189902200589 47.696296425003148, -114.09189900975508 47.696285688169844, -114.09189493399755 47.692710546997446)
     (-114.09186217621264 47.681865943425152, -114.09186216969943 47.68186714324343, -114.09186208299902 47.681883105996512, -114.09186217621264 47.681865943425152)
     (-114.09186706469841 47.683163676784858, -114.09187617200071 47.685504596001181, -114.09187605393174 47.685474249838911, -114.09186706469841 47.683163676784858)
     (-114.07065622300188 47.634730579998525, -114.07066675699576 47.638353347999754, -114.07065643000105 47.641980841003907, -114.06529951399644 47.641988080001923, -114.05994190300059 47.641995071004111, -114.05457509800517 47.64199653300269, -114.04920829099851 47.641997716999676, -114.04919325499931 47.63837883500409, -114.04919896999746 47.6347491190033, -114.05456452599768 47.634745379997739, -114.05993008199877 47.634741363002206, -114.0652931389955 47.634736096001141, -114.07065622300188 47.634730579998525)
     (-114.16677244674182 47.652930824638212, -114.16149302627555 47.652930822786281, -114.16149285399627 47.652903940003547, -114.16677244674182 47.652930824638212)
     (-114.11325582699743 47.641929283002106, -114.11325199700444 47.645541243000942, -114.10790024799974 47.6455476770008, -114.10790271809852 47.643740184002262, -114.11057832900541 47.643737758001244, -114.110579410996 47.642834400002911, -114.10790396700509 47.64283643699811, -114.10790272720927 47.643733520889654, -114.10790518800322 47.641932716999108, -114.11325582699743 47.641929283002106))
  2. Pavel R. Pavlov
    Admin
    Pavel R. Pavlov avatar
    1182 posts

    Posted 28 Aug 2014 Link to this post

    Hi Michael,
     
    I tried to use the provided data and to create a PolygonData object and to visualize it using the RadMap control and it seems that the polygon is visualized. I am not sure if this is the correct shape that you need to visualize.
    However, you need to keep in mind that the RadMap works with the Mercator projection. Also known as EPSG:4326 and if your coordinates are extracted in different projection the visualized shape will not look as you might expect it. This is why I would ask you to double check if the provided coordinates are created using Mercator projection.

    Regards,
    Pavel R. Pavlov
    Telerik
     
    Check out Telerik Analytics, the service which allows developers to discover app usage patterns, analyze user data, log exceptions, solve problems and profile application performance at run time. Watch the videos and start improving your app based on facts, not hunches.
     
  3. DevCraft banner
  4. Ludmila
    Ludmila avatar
    4 posts
    Member since:
    Jul 2010

    Posted 29 Aug 2014 in reply to Michael Link to this post

    Hello Michael,

    The approach you use will not work. The PolygonData is a wrong class to show polygon with interior rings. It can't show complex shapes. You have to use PathData instead. Something like this:

    PathData path = new PathData()
    {
        ShapeFill = new MapShapeFill()
        {
            Fill = new SolidColorBrush(Color.FromArgb(127, 0, 240, 255)),
            Stroke = new SolidColorBrush(Colors.Red),
            StrokeThickness = 2
        }
    };
     
    PathGeometryData geometry = new PathGeometryData();
     
    PathFigureData figure = new PathFigureData()
    {
        IsClosed = true,
        StartPoint = new Location(42.6957539183824, 23.3327663758679)
    };
     
    LocationCollection points = new LocationCollection();
    points.Add(new Location(42.1429369264591, 24.7498095849434));
    points.Add(new Location(42.5131732087098, 27.4611884843576));     
    points.Add(new Location(43.2073941930888, 27.9275176988258));
    points.Add(new Location(43.1957539183824,23.5427663758679));
     
    PolyLineSegmentData segment = new PolyLineSegmentData()
    {
        Points = points
    };
    figure.Segments.Add(segment);
    geometry.Figures.Add(figure);
     
    figure = new PathFigureData()
    {
        IsClosed = true,
        StartPoint = new Location(42.6957539183824, 23.8327663758679)
    };
     
    points = new LocationCollection();
    points.Add(new Location(42.3429369264591, 24.7498095849434));
    points.Add(new Location(42.6131732087098, 26.9611884843576));
    points.Add(new Location(43.0073941930888, 27.3275176988258));
    points.Add(new Location(42.9957539183824, 23.9427663758679));
     
    segment = new PolyLineSegmentData()
    {
        Points = points
    };
    figure.Segments.Add(segment);
    geometry.Figures.Add(figure);
     
    path.Data = geometry;
     
    this.visualizationLayer.Items.Add(path);

    By the way, the RadMap control has built-in support for the WKT/WKB format. Why you simple don't use? You can find example here. This example is for the InformationLayer, but similar functionality is available for VisualizationLayer as well.

    Best Regards
    Ludmila Murzova
Back to Top