This is returning an array of points inside points for polygons and lines, because polygons and lines are parsed in a recursive fashion. The attached patch fixes it so that geo_wkb_get_data($wkb, 'array') always returns an array of lat/lon pairs--the same structure of points whether the data is a point, linestring, or polygon:

Array
(
    [byte_order] => 1
    [type] => polygon
    [count] => 1
    [value] => Array
        (
            [0] => Array
                (
                    [0] => 41.469534
                    [1] => -88.263478
                )

            [1] => Array
                (
                    [0] => 41.469534
                    [1] => -87.111162
                )

            [2] => Array
                (
                    [0] => 42.154324
                    [1] => -87.111162
                )

            [3] => Array
                (
                    [0] => 42.154324
                    [1] => -88.263478
                )

            [4] => Array
                (
                    [0] => 41.469534
                    [1] => -88.263478
                )

        )

)

Comments

becw’s picture

Status: Active » Needs review
greggles’s picture

Attached patch provides
1. bec's original array code
2. Updated formatters
3. Code in geo.module to make sure that the wkb is in wkb instead of {field_name_}wkb
4. Some initial work toward making views lat/lon work again, but this is still basically broken.

becw’s picture

I think that these things should go in separate patches--one patch for each significant fix/feature.

greggles’s picture

Afaict, the only piece that's unrelated to the original patch is #4 which doesn't even work and can easily be excluded because it's in a single file.

The rest are at least somewhat related to the way that this patch restructures the array.

becw’s picture

ah, from your description it wasn't clear how 2 & 3 were related--I should have read the patch first (:

allie micka’s picture

Hi all,

I wanted to keep an array structure that's compatible with the original data. A polygon may have more than one segment, so this may be really important.

Additionally, there's a *ton* of confusion surrounding X, Y, Lat, Lon, 0, 1, etc. I think it's really important to use keyed arrays to mitigate confusion. Thus, the structure looks like:

For polygons:

Array
(
    [byte_order] => 1
    [type] => polygon
    [count] => 1
    [value] => Array
        (
            [0] => Array
                (
                    [0] => Array
                        (
                            [lon] => -95.153323532511
                            [lat] => 49.19310856029
                        )

                    [1] => Array
                        (
                            [lon] => -95.153424
                            [lat] => 49.249995
                        )
...

For linestrings

Array
(
    [byte_order] => 1
    [type] => linestring
    [count] => 18
    [value] => Array
        (
            [0] => Array
                (
                    [lon] => -96.6796875
                    [lat] => 39.7265625
                )

            [1] => Array
                (
                    [lon] => -90
                    [lat] => 46.0546875
                )

...

For points

Array
(
    [byte_order] => 1
    [type] => point
    [x] => -93.3439291
    [y] => 44.9465193
    [value] => Array
        (
            [lon] => -93.3439291
            [lat] => 44.9465193
        )

)

It's still not 100% perfect, but I'm hopeful that the basic structure will work well. I have committed this change, which means that the code requiring this correction (namely GMAP Geo) will have to account for it. I'll file patches accordingly.

I have not addressed the formatters/other issues, though I can't reproduce them either?

Thanks!

swill’s picture

Is there any progress getting Geo points mapped in a Gmap View? I have tried everything I can think of including these patches and I have not been able to get the Geo points to map correctly.

becw’s picture

This issue has been mostly resolved by recent commits -- http://drupal.org/cvs?commit=219310 -- but I'm finding that lat and lon are reversed in the array I get out of geo_wkb_get_array(). Possibly because WKT values are POINT(lon lat)?

becw’s picture

Status: Needs review » Fixed

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.