OpenLayers OpenLayers

Ticket #1192: getVertice_getEdges.00.patch

File getVertice_getEdges.00.patch, 6.0 kB (added by fredj, 1 year ago)

implement getVertices and getEdges but without unit tests ...

  • lib/OpenLayers/Geometry.js

    old new  
    186186    }, 
    187187 
    188188    /** 
     189     * Method: getVertices 
     190     * Returns all the vertices of the geometry.This method is  
     191     * defined in subclasses. 
     192     * 
     193     * Return: 
     194     * {Array(<OpenLayers.Geometry.Point>)} Vertices 
     195     */ 
     196    getVertices: function() { 
     197        return []; 
     198    }, 
     199     
     200    /** 
     201     * Method: getEdges 
     202     * Returns all the edges of the geometry.This method is  
     203     * defined in subclasses. 
     204     * 
     205     * Return: 
     206     * {Array(<OpenLayers.Geometry.Point>)} Edges 
     207     */ 
     208    getEdges: function() { 
     209        return []; 
     210    }, 
     211 
     212    /** 
    189213     * Method: toString 
    190214     * Returns the Well-Known Text representation of a geometry 
    191215     * 
  • lib/OpenLayers/Feature/Vector.js

    old new  
    179179    }, 
    180180 
    181181    /** 
     182     * Method: getVertices 
     183     * Returns all the vertices of the geometry. 
     184     * 
     185     * Return: 
     186     * {Array(<OpenLayers.Geometry.Point>)} Vertices 
     187     */ 
     188    getVertices: function() { 
     189        if (this.geometry) { 
     190            return this.geometry.getVertices(); 
     191        } else { 
     192            return []; 
     193        } 
     194    }, 
     195 
     196    /** 
     197     * Method: getEdges 
     198     * Returns all the edges of the geometry. 
     199     * 
     200     * Return: 
     201     * {Array(<OpenLayers.Geometry.Point>)} Edges 
     202     */ 
     203    getEdges: function() { 
     204        if (this.geometry) { 
     205            return this.geometry.getEdges(); 
     206        } else { 
     207            return []; 
     208        } 
     209    }, 
     210 
     211    /** 
    182212     * Method: destroyPopup 
    183213     * HACK - we need to decide if all vector features should be able to 
    184214     * delete popups 
  • lib/OpenLayers/Geometry/Polygon.js

    old new  
    3838                                                                  arguments); 
    3939    }, 
    4040     
     41    /** 
     42     * Method: getEdges 
     43     * Returns all the edges of the geometry. 
     44     * 
     45     * Return: 
     46     * {Array(<OpenLayers.Geometry.Point>)} Edges 
     47     */ 
     48    getEdges: function() { 
     49        var edges = []; 
     50        for (var i = 0; i < this.components.length; i++) { 
     51            edges = edges.concat(this.components[i].getEdges()); 
     52        } 
     53        return edges; 
     54    }, 
     55 
    4156    /**  
    4257     * APIMethod: getArea 
    4358     * Calculated by subtracting the areas of the internal holes from the  
  • lib/OpenLayers/Geometry/Point.js

    old new  
    116116    toShortString: function() { 
    117117        return (this.x + ", " + this.y); 
    118118    }, 
     119 
     120 
     121    /** 
     122     * Method: getVertices 
     123     * Returns all the vertices of the geometry. 
     124     * 
     125     * Return: 
     126     * {Array(<OpenLayers.Geometry.Point>)} Vertices 
     127     */ 
     128    getVertices: function() { 
     129        return [this]; 
     130    }, 
    119131     
    120132    /** 
    121133     * APIMethod: move 
  • lib/OpenLayers/Geometry/LinearRing.js

    old new  
    8181         
    8282        return added; 
    8383    }, 
     84 
     85    /** 
     86     * Method: getVertices 
     87     * Returns all the vertices of the geometry. 
     88     * 
     89     * Return: 
     90     * {Array(<OpenLayers.Geometry.Point>)} Vertices 
     91     */ 
     92    getVertices: function() { 
     93        return this.components.slice(0, this.components.length - 1); 
     94    }, 
     95 
    8496     
    8597    /** 
    8698     * APIMethod: removeComponent 
  • lib/OpenLayers/Geometry/Collection.js

    old new  
    9797        return strings.join(","); 
    9898    }, 
    9999 
     100 
    100101    /** 
     102     * Method: getVertices 
     103     * Returns all the vertices of the geometry. 
     104     * 
     105     * Return: 
     106     * {Array(<OpenLayers.Geometry.Point>)} Vertices 
     107     */ 
     108    getVertices: function() { 
     109        var vertices = []; 
     110        for(var i = 0; i < this.components.length; i++) { 
     111            vertices = vertices.concat(this.components[i].getVertices());  
     112        } 
     113        return vertices; 
     114    }, 
     115 
     116    /** 
    101117     * APIMethod: calculateBounds 
    102118     * Recalculate the bounds by iterating through the components and  
    103119     * calling calling extendBounds() on each item. 
  • lib/OpenLayers/Geometry/LineString.js

    old new  
    2828    }, 
    2929 
    3030    /** 
     31     * Method: getVertices 
     32     * Returns all the vertices of the geometry. 
     33     * 
     34     * Return: 
     35     * {Array(<OpenLayers.Geometry.Point>)} Vertices 
     36     */ 
     37    getVertices: function() { 
     38        return this.components; 
     39    }, 
     40 
     41    /** 
     42     * Method: getEdges 
     43     * Returns all the edges of the geometry. 
     44     * 
     45     * Return: 
     46     * {Array(<OpenLayers.Geometry.Point>)} Edges 
     47     */ 
     48    getEdges: function() { 
     49        var edges = []; 
     50        for (var i = 0; i < this.components.length - 1; i++) { 
     51            var start = this.components[i].clone(); 
     52            var stop = this.components[i + 1].clone(); 
     53            edges = edges.concat(new OpenLayers.Geometry.LineString([start, stop])); 
     54        } 
     55        return edges; 
     56    }, 
     57 
     58    /** 
    3159     * APIMethod: removeComponent 
    3260     * Only allows removal of a point if there are three or more points in  
    3361     * the linestring. (otherwise the result would be just a single point)