Ticket #1360 (closed bug: fixed)

Opened 5 years ago

Last modified 5 years ago

SVG renderer draws features in the upperleft corner of the map pane when coordinate outside range

Reported by: ahocevar Owned by:
Priority: minor Milestone: 2.6 Release
Component: Renderer.SVG Version: 2.5
Keywords: Cc: seb@…
State: Complete

Description

The inValidRange check in Renderer.SVG is handled correctly for rectangles, but not for circles. Removing the node (like previously even improved in #1274) is useless, because it will be re-added after calling drawGeometryNode() in Renderer.Elements. The proposed patch changes the renderer so points/circles outside the valid range will be given "" coordinates and zero radius instead of removing the node.

Attachments

1360-r6240-A0.patch Download (2.1 KB) - added by ahocevar 5 years ago.
1360-r6496-B0.patch Download (1.0 KB) - added by ahocevar 5 years ago.

Change History

Changed 5 years ago by ahocevar

  Changed 5 years ago by ahocevar

Please ignore the first patch, this was for a different ticket. The correct patch is 1360-r6240-A0.patch. All tests pass in FF.

  Changed 5 years ago by tschaub

  • state changed from Review to Commit

Looks good.

  Changed 5 years ago by ahocevar

  • status changed from new to closed
  • state changed from Commit to Complete
  • resolution set to fixed

(In [6380]) SVG renderer draws features in the upperleft corner of the map pane when coordinate outside range. r=tschaub (closes #1360)

  Changed 5 years ago by tschaub

  • status changed from closed to reopened
  • state changed from Complete to Needs More Work
  • resolution fixed deleted

Haven't taken the time to see if this is the same or a different issue, but the description matches. Take a look at this example:

<html xmlns="http://www.w3.org/1999/xhtml">
  <head>
    <link rel="stylesheet" href="../theme/default/style.css" type="text/css" />
    <style type="text/css">
        #map {
            width: 512px;
            height: 512px;
            border: 1px solid gray;
        }
    </style>

    <script src="../lib/OpenLayers.js"></script>
    <script type="text/javascript">
        var map, point;

        function init(){
            var options = {
                projection: new OpenLayers.Projection("EPSG:900913"),
                displayProjection: new OpenLayers.Projection("EPSG:4326"),
                units: "m",
                maxResolution: 20, //0.07464553542137146,
                maxExtent: new OpenLayers.Bounds(-20037508, -20037508,
                                                 20037508, 20037508.34)
            };
            map = new OpenLayers.Map('map', options);
            var vector = new OpenLayers.Layer.Vector(
                    "Vectors",
                    {isBaseLayer: true}
            );
            map.addLayer(vector);

            var x =  -8234554.33791754;
            var y = 4981644.9249702;
            point = new OpenLayers.Feature.Vector(
                new OpenLayers.Geometry.Point(x, y)
            );
            
            map.addLayer(vector);
            vector.addFeatures([point]);
            map.setCenter(new OpenLayers.LonLat(0, 0), 5);
        }
        
        function pan(){
            map.panTo(point.geometry.getBounds().getCenterLonLat());
        }

    </script>
  </head>
  <body onload="init()">
    <h3 id="title">SVG Test</h3>
    <div id="map"></div>
    <input type="button" value="Go!" onclick="pan();"></input>
  </body>
</html>

  Changed 5 years ago by sbenthall

  • cc sbenthall added

  Changed 5 years ago by sbenthall

  • cc seb@… added; sbenthall removed

  Changed 5 years ago by crschmidt

Apparently:

            node.setAttributeNS(null, "cx", "");
            console.log(node.getAttributeNS(null, "cx"));

returns "0" in the console.log call. Apparently cx cant be set to an null string? (This is in drawCircle.)

Changed 5 years ago by ahocevar

follow-up: ↓ 9   Changed 5 years ago by ahocevar

  • state changed from Needs More Work to Review

1360-r6496-B0.patch fixes the issue that the out-of-range point is shown in the upper-left corner of the map.

But unlike the VML renderer, the SVG renderer will not show the point after re-centering to the point, because it is still outside the valid coordinates ranges. This would require to redraw the layer, but the renderer does not know about the layer. We have to figure out something to fix this.

in reply to: ↑ 8   Changed 5 years ago by ahocevar

Replying to ahocevar:

But unlike the VML renderer, the SVG renderer will not show the point after re-centering to the point, because it is still outside the valid coordinates ranges.

Actually it is not, but just recentering the map will not cause the renderer to re-check that.

  Changed 5 years ago by ahocevar

I created #1431 to track the issue described in comment:8.

  Changed 5 years ago by crschmidt

  • state changed from Review to Commit

I think that #1431 has always been with us. Certainly, I've bumped into it before. Anyway, this looks like a fine fix for this problem, and helps alleviate part of the problem: fixing #1431 (as you pointed out) is more difficult, but can come after this.

Please commit.

  Changed 5 years ago by ahocevar

  • status changed from reopened to closed
  • state changed from Commit to Complete
  • resolution set to fixed

(In [6515]) Prevent SVG renderer from drawing features in the upperleft corner of the map pane when coordinates are outside range. The fix in r6380 did not work properly. r=crschmidt (closes #1360)

Note: See TracTickets for help on using tickets.