Removing polygon holes in OpenLayersJTS Polygon simplification without holesGeoserver : create a rasterized polygon / dynamic fill for polygons with features from databaseGeoserver and “inverting” a multiPolygon to dim the rest of a mapOpenLayers 3: Digitizing holes (donut polygons)St_delaunaytriangles polygon with holesAutomated way to create polygons from coloured mapgrid data to contoursFix slivers (Holes) between polygons ( generated after removing spikes)OGR multipolygon with holes modelHow to inverse the orientation of the holes coordinates of a polygon in geopandas

Are there any double stars that I can actually see orbit each other?

What is this welding tool I found in my attic?

What can the U.S. government do to prevent powerful people to get extremely favorable plea bargain deals like Jeff Epstein?

How to check the quality of an audio sample?

Are neural networks prone to catastrophic forgetting?

Does Google Maps take into account hills/inclines for route times?

Why did my rum cake turn black?

Password maker in c#

Filtering fine silt/mud from water (not necessarily bacteria etc.)

Cops: The Hidden OEIS Substring

Crowbar circuit causes unexpected behavior for op amp circuit

A DVR algebra with weird automorphisms

Why are Hobbits so fond of mushrooms?

Is Trump personally blocking people on Twitter?

Using ”as” after dialogue tags

<schwitz>, <zwinker> etc. Does German always use 2nd Person Singular Imperative verbs for emoticons? If so, why?

What would the EU do if an EU member declared war on another EU member?

Who Can Help Retag This?

The monorail explodes before I can get on it

QGIS Welcome page: What is 'pin to list' for?

How might the United Kingdom become a republic?

Why does Hellboy file down his horns?

How can an advanced civilization forget how to manufacture its technology?

Why do players in the past play much longer tournaments than today's top players?



Removing polygon holes in OpenLayers


JTS Polygon simplification without holesGeoserver : create a rasterized polygon / dynamic fill for polygons with features from databaseGeoserver and “inverting” a multiPolygon to dim the rest of a mapOpenLayers 3: Digitizing holes (donut polygons)St_delaunaytriangles polygon with holesAutomated way to create polygons from coloured mapgrid data to contoursFix slivers (Holes) between polygons ( generated after removing spikes)OGR multipolygon with holes modelHow to inverse the orientation of the holes coordinates of a polygon in geopandas






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;








5















I wrote some code for removal of polygon holes whose area value is under the hardcoded threshold.



source_g.getFeatures()[0].getGeometry().getPolygons().forEach(function(poly)

if(!(poly.getLinearRings().length<=1))

poly.getLinearRings().forEach(function(ring)
if(Math.abs(ring.getArea()) < 0.1)

ring.setCoordinates([])

)
;
)


The idea is to set coordinates of inner LinearRings to [], I tried to do that on the whole feature and it disappeared. But for LinearRings it's not doing the same.










share|improve this question






























    5















    I wrote some code for removal of polygon holes whose area value is under the hardcoded threshold.



    source_g.getFeatures()[0].getGeometry().getPolygons().forEach(function(poly)

    if(!(poly.getLinearRings().length<=1))

    poly.getLinearRings().forEach(function(ring)
    if(Math.abs(ring.getArea()) < 0.1)

    ring.setCoordinates([])

    )
    ;
    )


    The idea is to set coordinates of inner LinearRings to [], I tried to do that on the whole feature and it disappeared. But for LinearRings it's not doing the same.










    share|improve this question


























      5












      5








      5








      I wrote some code for removal of polygon holes whose area value is under the hardcoded threshold.



      source_g.getFeatures()[0].getGeometry().getPolygons().forEach(function(poly)

      if(!(poly.getLinearRings().length<=1))

      poly.getLinearRings().forEach(function(ring)
      if(Math.abs(ring.getArea()) < 0.1)

      ring.setCoordinates([])

      )
      ;
      )


      The idea is to set coordinates of inner LinearRings to [], I tried to do that on the whole feature and it disappeared. But for LinearRings it's not doing the same.










      share|improve this question
















      I wrote some code for removal of polygon holes whose area value is under the hardcoded threshold.



      source_g.getFeatures()[0].getGeometry().getPolygons().forEach(function(poly)

      if(!(poly.getLinearRings().length<=1))

      poly.getLinearRings().forEach(function(ring)
      if(Math.abs(ring.getArea()) < 0.1)

      ring.setCoordinates([])

      )
      ;
      )


      The idea is to set coordinates of inner LinearRings to [], I tried to do that on the whole feature and it disappeared. But for LinearRings it's not doing the same.







      polygon openlayers holes






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Jul 4 at 10:52









      Taras

      3,2993 gold badges9 silver badges32 bronze badges




      3,2993 gold badges9 silver badges32 bronze badges










      asked Jul 4 at 9:49









      GoranGoran

      696 bronze badges




      696 bronze badges




















          1 Answer
          1






          active

          oldest

          votes


















          7














          The geometry is defined as an array of coordinates, not collections of Polygons and LinearRings, so what is returned by getPolygons() and getLinearRings() should be treated as clones and you will need to rebuild the geometry from coordinates



          var geom = source_g.getFeatures()[0].getGeometry();
          var geomCoords = [];
          geom.getPolygons().forEach(function(poly)
          var polyCoords = [];
          poly.getLinearRings().forEach(function(ring, index)
          if(index == 0 ;
          geomCoords.push(polyCoords);
          );
          geom.setCoordinates(geomCoords);





          share|improve this answer

























            Your Answer








            StackExchange.ready(function()
            var channelOptions =
            tags: "".split(" "),
            id: "79"
            ;
            initTagRenderer("".split(" "), "".split(" "), channelOptions);

            StackExchange.using("externalEditor", function()
            // Have to fire editor after snippets, if snippets enabled
            if (StackExchange.settings.snippets.snippetsEnabled)
            StackExchange.using("snippets", function()
            createEditor();
            );

            else
            createEditor();

            );

            function createEditor()
            StackExchange.prepareEditor(
            heartbeatType: 'answer',
            autoActivateHeartbeat: false,
            convertImagesToLinks: false,
            noModals: true,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: null,
            bindNavPrevention: true,
            postfix: "",
            imageUploader:
            brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
            contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
            allowUrls: true
            ,
            onDemand: true,
            discardSelector: ".discard-answer"
            ,immediatelyShowMarkdownHelp:true
            );



            );













            draft saved

            draft discarded


















            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fgis.stackexchange.com%2fquestions%2f327794%2fremoving-polygon-holes-in-openlayers%23new-answer', 'question_page');

            );

            Post as a guest















            Required, but never shown

























            1 Answer
            1






            active

            oldest

            votes








            1 Answer
            1






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes









            7














            The geometry is defined as an array of coordinates, not collections of Polygons and LinearRings, so what is returned by getPolygons() and getLinearRings() should be treated as clones and you will need to rebuild the geometry from coordinates



            var geom = source_g.getFeatures()[0].getGeometry();
            var geomCoords = [];
            geom.getPolygons().forEach(function(poly)
            var polyCoords = [];
            poly.getLinearRings().forEach(function(ring, index)
            if(index == 0 ;
            geomCoords.push(polyCoords);
            );
            geom.setCoordinates(geomCoords);





            share|improve this answer



























              7














              The geometry is defined as an array of coordinates, not collections of Polygons and LinearRings, so what is returned by getPolygons() and getLinearRings() should be treated as clones and you will need to rebuild the geometry from coordinates



              var geom = source_g.getFeatures()[0].getGeometry();
              var geomCoords = [];
              geom.getPolygons().forEach(function(poly)
              var polyCoords = [];
              poly.getLinearRings().forEach(function(ring, index)
              if(index == 0 ;
              geomCoords.push(polyCoords);
              );
              geom.setCoordinates(geomCoords);





              share|improve this answer

























                7












                7








                7







                The geometry is defined as an array of coordinates, not collections of Polygons and LinearRings, so what is returned by getPolygons() and getLinearRings() should be treated as clones and you will need to rebuild the geometry from coordinates



                var geom = source_g.getFeatures()[0].getGeometry();
                var geomCoords = [];
                geom.getPolygons().forEach(function(poly)
                var polyCoords = [];
                poly.getLinearRings().forEach(function(ring, index)
                if(index == 0 ;
                geomCoords.push(polyCoords);
                );
                geom.setCoordinates(geomCoords);





                share|improve this answer













                The geometry is defined as an array of coordinates, not collections of Polygons and LinearRings, so what is returned by getPolygons() and getLinearRings() should be treated as clones and you will need to rebuild the geometry from coordinates



                var geom = source_g.getFeatures()[0].getGeometry();
                var geomCoords = [];
                geom.getPolygons().forEach(function(poly)
                var polyCoords = [];
                poly.getLinearRings().forEach(function(ring, index)
                if(index == 0 ;
                geomCoords.push(polyCoords);
                );
                geom.setCoordinates(geomCoords);






                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered Jul 4 at 10:20









                MikeMike

                3,5731 gold badge3 silver badges10 bronze badges




                3,5731 gold badge3 silver badges10 bronze badges



























                    draft saved

                    draft discarded
















































                    Thanks for contributing an answer to Geographic Information Systems Stack Exchange!


                    • Please be sure to answer the question. Provide details and share your research!

                    But avoid


                    • Asking for help, clarification, or responding to other answers.

                    • Making statements based on opinion; back them up with references or personal experience.

                    To learn more, see our tips on writing great answers.




                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function ()
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fgis.stackexchange.com%2fquestions%2f327794%2fremoving-polygon-holes-in-openlayers%23new-answer', 'question_page');

                    );

                    Post as a guest















                    Required, but never shown





















































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown

































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown







                    Popular posts from this blog

                    Get product attribute by attribute group code in magento 2get product attribute by product attribute group in magento 2Magento 2 Log Bundle Product Data in List Page?How to get all product attribute of a attribute group of Default attribute set?Magento 2.1 Create a filter in the product grid by new attributeMagento 2 : Get Product Attribute values By GroupMagento 2 How to get all existing values for one attributeMagento 2 get custom attribute of a single product inside a pluginMagento 2.3 How to get all the Multi Source Inventory (MSI) locations collection in custom module?Magento2: how to develop rest API to get new productsGet product attribute by attribute group code ( [attribute_group_code] ) in magento 2

                    Category:9 (number) SubcategoriesMedia in category "9 (number)"Navigation menuUpload mediaGND ID: 4485639-8Library of Congress authority ID: sh85091979ReasonatorScholiaStatistics

                    Magento 2.3: How do i solve this, Not registered handle, on custom form?How can i rewrite TierPrice Block in Magento2magento 2 captcha not rendering if I override layout xmlmain.CRITICAL: Plugin class doesn't existMagento 2 : Problem while adding custom button order view page?Magento 2.2.5: Overriding Admin Controller sales/orderMagento 2.2.5: Add, Update and Delete existing products Custom OptionsMagento 2.3 : File Upload issue in UI Component FormMagento2 Not registered handleHow to configured Form Builder Js in my custom magento 2.3.0 module?Magento 2.3. How to create image upload field in an admin form