This is a simple module that adds mbtiles layer type to the OpenLayers Module in Drupal 7.

It is a functionality I needed for the development of the myregion.gov.au project which uses tilestache to render mbtiles generated with TileMill. Without this module there is no way to make the mbtiles render in the correct Y-axis order which renders the map incorrectly.

The sandbox project can be found here: http://drupal.org/sandbox/rubenspeculis/1757754

It can be cloned:

git clone --recursive --branch 7.x-1.x http://git.drupal.org/sandbox/rubenspeculis/1757754.git mbtiles_for_openlayers

I will update this once I have done some reviews.

Kind regards,

Rubens

Comments

2pha’s picture

My first review !

You are still working in the master branch. Please checkout the following documentation to eliminate this problem. http://drupal.org/empty-git-master

Please checkout the errors pointed out by the automated review : http://ventral.org/pareview/httpgitdrupalorgsandboxrubenspeculis1757754

2pha’s picture

Status: Needs review » Needs work
amitgoyal’s picture

1.Please add git link corresponding to non-maintainer like "git clone http://git.drupal.org/sandbox/rubenspeculis/1757754.git mbtiles_for_openlayers" in the issue summary.
2. In .info file
Remove ; $Id$ on line 1.
2. In mbtiles_for_openlayers.module, mbtiles_for_openlayers_uninstall() : The uninstall hook must be implemented in the module's .install file refer http://api.drupal.org/api/drupal/modules!system!system.api.php/function/....
3. Not required : drupal_uninstall_schema('mbtiles_for_openlayers');
as tables defined in the module are removed automatically when the module is uninstalled refer http://api.drupal.org/api/drupal/modules!system!system.api.php/function/....

rubenspeculis’s picture

Status: Needs work » Needs review

Thanks @2pha and @amitigoyal.

1. I've moved out of master and updated the git link.
2. I've removed the non-needed line from the .info file
3. I've moved the uninstall hook to the .install file
4. I've removed the superfluous drupal_uninstall_schema()

Thanks for your support guys. Please review the changes.

Thanks,

Rubens

andrewkamm’s picture

Hi Rubens,

The .info file should be formatted a bit better, mostly just the use of proper capitalization (ex: "MBTiles, "OpenLayers" rather than "mbtiles", "openlayers"). It's also safe (though optional) to remove the quotes from around the values, even ones with whitespace (as long as there are no line breaks in those values). The detailed recommendations for .info files are at http://drupal.org/node/542202.

The .install file has a typo in the @file comment ("openalyers"). Also in the .install, the title and description elements in the array returned by mbtiles_for_openlayers_openlayers_layer_types() should be given proper capitalization as noted for the .info file.

In your implementation of hook_uninstall(), you're using SQL and db_query() to remove variables. You should instead use the variable_del() function provided by Drupal. Your query searches for vars starting with mbtiles_for_openlayers_, and you can replicate that behavior and still use

variable_del()<code> by using the method the OpenLayers module itself uses: 

<pre><code>
/**
 * Implements hook_uninstall().
 */
function openlayers_uninstall() {
  // Get module variables
  $variables = db_query("SELECT v.name FROM {variable} AS v WHERE v.name LIKE ':pattern'",
    array(':pattern' => db_like('openlayers_') . '%'))->fetchAll();
  // Remove variables
  foreach ($variables as $v) {
    variable_del($v);
  }
}

In your repository, you've got the major version branch (7.x-1.x) as default, but you should also remove the master branch entirely. The process for doing this with a Drupal-hosted project is documented here.

I ran the Coder module reviews, and everything came back clean.

I was able to create a new MBTiles layer and use it on a new map without a problem, except that the map tiles don't show up for me -- however, I'm assuming that's because I need to have a value set for "Base URL" when defining the MBTiles layer. This is my first time using MBTiles, so I'm guessing I would know what to use there if I was more familiar with it. If there's a public URL that can be plugged in there, let me know and I'll try it out.

bhosmer’s picture

Status: Needs review » Needs work

Setting to needs work.

klausi’s picture

Status: Needs work » Closed (won't fix)

Closing due to lack of activity. Feel free to reopen if you are still working on this application.

If you reopen this please keep in mind that we are currently quite busy with all the project applications and I can only review projects with a review bonus. Please help me reviewing and I'll take a look at your project right away :-)

klausi’s picture

Issue summary: View changes

*Updated for non-maintainers git source