Refer also to: #690864: Openlayers Upgrade Path for 0.x to 2.x (and ensure that schema version is correct)

Currently there is some code that deals with the schema change but does not deal with the major data structures in the map array.

Also, Tom, you should not announce there is a clear upgrade path from 1.x.

Comments

tmcw’s picture

Status: Active » Closed (works as designed)

The upgrade path from 1.x to 2.x is by running the schema hook and manually upgrading layers and presets. Since there is a growing amount of documentation for 2.x, I think that this is reasonably clear. I'm not planning on writing the very complex code it would take to automatically do this when the majority of OpenLayers configurations are quite simple, and the 1.x branch doesn't have a huge installed base.

Patches are welcome, but for the time being this is by design, because it's stated everywhere that the upgrade path is manual but documented.

zzolo’s picture

Assigned: Unassigned » zzolo
Status: Closed (works as designed) » Active

I would very much disagree. Saying "it's manual" is not an upgrade path. This is a manual upgrade path.

I never had any expectations that you would create an upgrade path from 1.x. But I have always had plans to create an upgrade path, which involves some automatic conversions and documentation of manual changes. I have made this very clear since the beginning of 2.x.

Also, 1.x is still being worked on. It went RC1 yesterday. It'll go 1.0 soon and be done.

zzolo’s picture

We also want to note API changes. Note some of this may be out of date (taking it form the advance_help)

Hooks

1.x:

function hook_openlayers_map_preprocess_alter(&$map = array()) {}
function hook_openlayers_map_alter(&$map = array()) {}
function hook_openlayers_behaviors_info() {}
function hook_openlayers_layers_handler_info($map = array()) {}
function hook_openlayers_layers_info() {}
function hook_openlayers_presets() {}
function hook_openlayers_styles_info() {}

2.x:

Major API

1.x:

openlayers_initialize()
openlayers_render_map($map = array(), $render = TRUE)
openlayers_layers_get_info($reset = FALSE)
openlayers_behaviors_get_info($reset = FALSE)
openlayers_styles_get_info($reset = FALSE)
openlayers_save_preset($preset = array())
openlayers_get_preset($name = '', $reset = FALSE)
openlayers_get_map($id = '')
openlayers_presets($reset = FALSE)
openlayers_get_presets($format = 'simple', $reset = FALSE)
openlayers_get_default_map($reset = FALSE)
openlayers_merge_maps($map1 = array(), $map2 = array())
openlayers_error_check_map($map, $log_errors = TRUE)

2.x:

Theming

1.x:

theme_openlayers_map($map = array())
theme_openlayers_vector_styles($styles = array(), $map = array())
theme_openlayers_behaviors_tooltip_container($behavior = array(), $map = array())
theme_openlayers_presets_ui_form_layer_description($layer_title = '', $layer_description = '')
theme_openlayers_presets_ui_form_projection_description($projection_title = '', $available_layers = array(), $layers = array())
theme_openlayers_views_feature_style($view = NULL, $row = NULL, $group = NULL) 

2.x:

zzolo’s picture

Compare the map arrays/objects to note changes.

1.x:

  $default_map = array(
    'id' => 'XXXX',
    'projection' => '4326',
    'width' => 'auto',
    'default_layer' => 'openlayers_default_wms',
    'height' => '300px',
    'center' => array(
      'lat' => '0',
      'lon' => '0',
      'zoom' => '2',
    ),
    'options' => array(
      'displayProjection' => '4326',
      'maxResolution' => 156543.0339,
      'maxExtent' => array(
        'left' => -20037508.34,
        'bottom' => -20037508.34,
        'right' => 20037508.34,
        'top' => 20037508.34,
      ),
      'fractionalZoom' => '??',
    ),
    'controls' => array(
      'LayerSwitcher' => TRUE,
      'Navigation' => TRUE,
      'PanZoomBar' => TRUE,
      'MousePosition' => TRUE,
      'Attribution' => TRUE,
      'KeyboardDefaults' => TRUE,
      'Permalink' => TRUE,
      'ScaleLine' => TRUE,
      'ZoomBox' => TRUE,
      'ZoomToMaxExtent  ' => TRUE,
    ),
    'behaviors' => array(
      'openlayers_behaviors_fullscreen_test' => array(
        'id' => 'openlayers_behaviors_fullscreen_test',
        'type' => 'openlayers_behaviors_fullscreen',
      ),
      'cluster_example' => array(
        'id' => 'cluster_example',
        'type' => 'openlayers_behaviors_cluster',
        'layer' => 'default_vector',
        'distance' => '20',
        'threshold' => '1',
      ),
      'openlayers_behaviors_zoom_to_layer' => array(
        'id' => 'XX',
        'type' => 'openlayers_behaviors_zoom_to_layer',
        'layer' => 'default_vector',
      ),
      'openlayers_behaviors_zoom_to_feature' => array(
        'id' => 'XX',
        'type' => 'openlayers_behaviors_zoom_to_feature',
        'layer' => 'default_vector',
        'feature' => '', // Can be array of strings or string
      ),
      'openlayers_behaviors_tooltip' => array(
        'id' => 'XX',
        'type' => 'openlayers_behaviors_tooltip',
        'layer' => 'default_vector',
        'attribute' => 'XXX',
        'tooltip_id' => 'XXX',
        'container_id' => 'XXX',
        'attribute_id' => 'XXX',
        'offset_top' => 'XXX',
        'offset_left' => 'XXX',
      ),
      'openlayers_behaviors_draw_features' => array(
        'id' => 'XX',
        'type' => 'openlayers_behaviors_draw_features',
        'layer' => 'default_vector',
      ),
      'openlayers_behaviors_fullscreen' => array(
        'id' => 'XX',
        'type' => 'openlayers_behaviors_fullscreen',
      ),
      'openlayers_behaviors_declutter' => array(
        'id' => 'XX',
        'type' => 'openlayers_behaviors_declutter',
      ),
      'openlayers_behaviors_popup' => array(
        'id' => 'XX',
        'type' => 'openlayers_behaviors_popup',
        'attribute' => 'XXX',
      ),
    ),
    'styles' => array(
      'default',
      'default_select',
      'other' => array(
        'pointRadius' => 10,
        'fillColor' => '#333333',
        'strokeColor' => '#FFFFFF',
        'strokeWidth' => 4,
        'fillOpacity' => 0.75,
      ),
    ),
    // Layer Handlers:
    // WMS, Vector, KML, XYZ, Google, VirtualEarth, Yahoo, Cloudmade
    'layers' => array(
      'openlayers_default_wms',
      'openlayers_layers_nasa_global_mosaic',
      'openlayers_layers_nasa_daily_planet',
      'openlayers_layers_nasa_global_mosaic',
      'openlayers_layers_nasa_daily_planet',
      'openlayers_layers_nasa_blue_marble',
      'openlayers_layers_open_aerial',
      'openlayers_layers_google_street',
      'openlayers_layers_google_satellite',
      'openlayers_layers_google_hybrid',
      'openlayers_layers_google_physical',
      'openlayers_layers_yahoo_street',
      'openlayers_layers_yahoo_satellite',
      'openlayers_layers_yahoo_hybrid',
      'openlayers_layers_virtual_earth_street',
      'openlayers_layers_virtual_earth_satellite',
      'openlayers_layers_virtual_earth_hybrid',
      'openlayers_layers_osm_mapnik',
      'openlayers_layers_osm_tah',
      'openlayers_layers_osm_cycle',
      'openlayers_layers_osm_4326_hybrid',
      'openlayers_layers_cloudmade',
      'openlayers_default_wms',  
      'manual_layer_example_wms' => array(
        'id' => 'default_wms',
        'type'=> 'WMS',
        'name' => t('Default Open Layers WMS'),
        'url' => 'http://labs.metacarta.com/wms/vmap0',
        'params' => array(
          'layers' => 'basic',
        ),
        'options' => array(),
        'baselayer' => TRUE;
      ),
      'style_vector' => array(
        'id' => 'style_vector',
        'type' => 'Vector',
        'name' => t('Style Test Vector'),
        'features' => array(
          'feature_1' => array(
            'wkt' => 'POLYGON((1 1,5 1,5 5,1 5,1 1),(2 2, 3 2, 3 3, 2 3,2 2))',
            'attributes' => array(
              'name' => t('A Polygon with a hole in it'),
            ),
            'style' => array(
              'fillColor' => '#aa4400',
              'fillOpacity' => '0.7',
            ),
          ),
          'feature_2' => array(
            'lat' => '40.123',
            'lon' => '-20.123',
            'attributes' => array(
              'name' => t('A point'),
            ),
            'style' => array(
              'externalGraphic' => 'http://openlayers.org/dev/img/marker.png',
              'graphicWidth' => 21,
              'graphicHeight' => 25,
              'graphicXOffset' => 10,
              'graphicYOffset' => 10,
            ),
          ),
          'feature_3' => array(
            'wkt' => 'POINT(-20.123 -20.123)',
            'attributes' => array(
              'name' => t('Another point'),
            ),
          ),
          'feature_VV' => array(
            'wkt' => 'POLYGON((1 1,5 1,5 5,1 5,1 1),(2 2, 3 2, 3 3, 2 3,2 2))',
            'attributes' => array(
              'name' => 'A Polygon with a hole in it',
              'date' => 'December 24, 2004',
              'author' => 'Santa Claus',
            ),
            'style' => array(
              'fillColor' => '#aa4400',
              'fillOpacity' => '0.7',
            ),
          ),
          'feature_XX' => array(
            'lat' => '40.123',
            'lon' => '-20.123',
            'attributes' => array(
              'name' => 'A point',
              'date' => 'December 24, 2004',
              'author' => 'Rudolf',
            ),
            'style' => array(
              'externalGraphic' => 'http://openlayers.org/dev/img/marker.png',
              'graphicWidth' => 21,
              'graphicHeight' => 25,
              'graphicXOffset' => 10,
              'graphicYOffset' => 10,
            ),
          ),
        ),
      ),
    ),
  );

2.x:


zzolo’s picture

http://drupal.org/cvs?commit=328688

Put in initial automatic upgrade parts for the 1.x to 2.x upgrade. There's a fair amount of the map array that can be automated; of course we can only automate the things that are in the DB:

* General map properties
* Named layers
* (not in yet) but can save layer arrays if they are in the preset.
* Most of the behaviors can be transfer
* Styles can be (but still needs some work)

Major parts of the map presets that could use some work to have a smooth upgrade process:

* Vectors
* Features
* Behaviors (Cluster, Zoom to Feature, Tooltip, Draw Features, Declutter)

The next step which I will start right now is to make a D.o page describing the process. (Also, I am going to make a quick blog entry on how I set things up to easily test an upgrade.)

zzolo’s picture

Beginning of doc page: http://drupal.org/node/714366

Still needs work and better formatting.

Note that this ticket won't be fixed until 2.x is stable and we have agreed there will not be any API or data structure changes.

alex_b’s picture

Just upgraded 0.x->2.x upgrade with latest OL 2.x head and found that the 1.x->2.x upgrade executes and, of course, causes errors:

http://skitch.com/alexbarth/nikui/drupal-database-update-managing-news

- Via SQL terminal I verified that my previous schema version of the 0.x OL installation was as expected 6002.
- However drupal_get_installed_schema_version('openlayers'); in openlayers_update_6200() returns 6199 instead of the expected 6002.

This is a peculiar behavior of the update system. Requires more research on how to fix it/circumvent it. For the time being, can we remove the 1.x->2.x upgrade path until we've sorted out how it won't break 0.x ?

alex_b’s picture

Place to start reading: update_batch() in update.php. I see a drupal_set_installed_schema_version($module, $version - 1); in there :(

zzolo’s picture

@alex_b I think this is what Will was talking about in the other ticket. This seems like really silly behavior in Drupal.

Anyway, I am just going to go with the variable method, where we set something in the 1.x branch that we can manually test for in the upgrade; this is the simplest method. I should be able to address this tonight.

alex_b’s picture

I think this is what Will was talking about in the other ticket.

Yes - I just talked to Will about that. This behavior was not on my radar :\

I should be able to address this tonight.

That would be *great*. I am planning on a Managing News release tomorrow morning...

zzolo’s picture

Added variables to hook_update_6100 and hook_enable in 1.x:
http://drupal.org/cvs?commit=329134

zzolo’s picture

Changed logic in 2.x install file to use Drupal variable. I have tested with 1.x to 2.x upgrade but not with 0.x:
http://drupal.org/cvs?commit=329138

alex_b’s picture

I can confirm that 0.x -> 2.x upgrade is working fine - i. e. 1.x -> 2.x upgrade code is not being executed.

How are we looking for a 2.x alpha 2 release? Would be good to get the broken code off the project page.

zzolo’s picture

I personally have no problem with an alpha2, but would want to discuss more before a beta. I can do this real quick like.

zzolo’s picture

http://drupal.org/node/715384
Should show up in about 10 minutes.

alex_b’s picture

zzolo: thanks!

tmcw’s picture

Is this fixed, or are there other tasks remaining here?

zzolo’s picture

Yeah, I need to look at some more. Should be able to get to it this weekend.

tmcw’s picture

Is there continuing work on this ticket, for making automatic transitions from one version to the next?

zzolo’s picture

I've just been waiting for other changes to get it and things become stable. I don't want to put in too much time when things are still subject to change. Will try to address soon.

tmcw’s picture

The APIs are stable except for behaviors at this point, you can count on the rest, I think.

zzolo’s picture

Updating documentation to explain that Views will have to be manually upgraded as there is no way to automate the huge structural changes that have been made.
http://drupal.org/node/714366

I will still need to look at CCK. I would assume there is a way to upgrade things automatically.

tmcw’s picture

I think that we can mark this as very much fixed. The ticket is incredibly stale and this is no longer a hot topic or serious need for most users.

zzolo’s picture

I would like to keep this open until we at least have a beta as an upgrade path is not stable until then. I think the main thing that needs to get done here is the CCK stuff, which might actually already work, I just havent tested it out yet.

zzolo’s picture

Issue tags: +beta blocker

tagged as beta blocker

zzolo’s picture

Status: Active » Fixed

Alright, looked over CCK stuff. The WKT formats are different, but can still be handled fine in the 2.x version. Closing 'er down. Just to reiterate, documentation for upgrading from 1.x to 2.x here:

Upgrading OpenLayers 1.x to 2.x

tmcw’s picture

Great, thanks for finishing this.

Status: Fixed » Closed (fixed)
Issue tags: -beta blocker

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