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

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

                    Circuit construction for execution of conditional statements using least significant bitHow are two different registers being used as “control”?How exactly is the stated composite state of the two registers being produced using the $R_zz$ controlled rotations?Efficiently performing controlled rotations in HHLWould this quantum algorithm implementation work?How to prepare a superposed states of odd integers from $1$ to $sqrtN$?Why is this implementation of the order finding algorithm not working?Circuit construction for Hamiltonian simulationHow can I invert the least significant bit of a certain term of a superposed state?Implementing an oracleImplementing a controlled sum operation

                    Magento 2 “No Payment Methods” in Admin New OrderHow to integrate Paypal Express Checkout with the Magento APIMagento 1.5 - Sales > Order > edit order and shipping methods disappearAuto Invoice Check/Money Order Payment methodAdd more simple payment methods?Shipping methods not showingWhat should I do to change payment methods if changing the configuration has no effects?1.9 - No Payment Methods showing upMy Payment Methods not Showing for downloadable/virtual product when checkout?Magento2 API to access internal payment methodHow to call an existing payment methods in the registration form?