Skip to content

Commit

Permalink
Merge bb9defc into 3d78395
Browse files Browse the repository at this point in the history
  • Loading branch information
keshrath committed May 1, 2019
2 parents 3d78395 + bb9defc commit 311185e
Show file tree
Hide file tree
Showing 8 changed files with 160 additions and 0 deletions.
36 changes: 36 additions & 0 deletions geoengine_bing/README.rst
@@ -0,0 +1,36 @@
.. image:: https://img.shields.io/badge/licence-AGPL--3-blue.svg
:alt: License

Geoengine Bing
==============

This module adds Bing raster support. A Bing API key is required to use this features.

Bug Tracker
===========

Bugs are tracked on `GitHub Issues <https://github.com/OCA/geospatial/issues>`_.
In case of trouble, please check there if your issue has already been reported.
If you spotted it first, help us smashing it by providing a detailed and welcomed feedback.

Credits
=======

Contributors
------------

* Kerrim Abdelhamed <kerrim.abdelhamed@mukit.at>
* Mathias Markl <mathias.markl@mukit.at>

Maintainer
----------

.. image:: http://odoo-community.org/logo.png
:alt: Odoo Community Association
:target: http://odoo-community.org

This module is maintained by the OCA.

OCA, or the Odoo Community Association, is a nonprofit organization whose mission is to support the collaborative development of Odoo features and promote its widespread use.

To contribute to this module, please visit http://odoo-community.org.
4 changes: 4 additions & 0 deletions geoengine_bing/__init__.py
@@ -0,0 +1,4 @@
# Copyright 2019 MuK IT GmbH - Kerrim Abd El-Hamed
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

from . import geo_view
24 changes: 24 additions & 0 deletions geoengine_bing/__manifest__.py
@@ -0,0 +1,24 @@
# Copyright 2019 MuK IT GmbH - Kerrim Abd El-Hamed
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

{
"name": "GeoEngine Bing Raster Support",
"version": "12.0.1.0.0",
"author": "MuK IT,Odoo Community Association (OCA)",
"category": "GeoBI",
"license": "AGPL-3",
"depends": [
"base_geoengine",
],
"contributors": [
"Kerrim Abdelhamed <kerrim.abdelhamed@mukit.at>",
"Mathias Markl <mathias.markl@mukit.at>",
],
"data": [
"geo_view/geo_raster_layer_view.xml",
"views/geoengine_bing_view.xml",
],
"installable": True,
"auto_install": False,
"application": False,
}
4 changes: 4 additions & 0 deletions geoengine_bing/geo_view/__init__.py
@@ -0,0 +1,4 @@
# Copyright 2019 MuK IT GmbH - Kerrim Abd El-Hamed
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

from . import geo_raster_layer
33 changes: 33 additions & 0 deletions geoengine_bing/geo_view/geo_raster_layer.py
@@ -0,0 +1,33 @@
# Copyright 2019 MuK IT GmbH - Kerrim Abd El-Hamed
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

import logging

from odoo import models, api, fields

_logger = logging.getLogger(__name__)

class GeoengineRasterLayer(models.Model):


_inherit = "geoengine.raster.layer"

raster_type = fields.Selection(selection_add=[('bing', 'Bing')])
is_bing = fields.Boolean(compute='_compute_is_bing')

bing_imagery_set = fields.Selection([
('Road', 'Road'),
('RoadOnDemand', 'Road on demand'),
('Aerial', 'Aerial'),
('AerialWithLabels', 'Aerial with labels'),
('collins Bart', 'Collins Bart'),
('ordnanceSurvey', 'Ordnance Survey')
], string="Imagery Set", default="AerialWithLabels")

bing_key = fields.Char()

@api.multi
@api.depends('raster_type')
def _compute_is_bing(self):
for rec in self:
rec.is_bing = rec.raster_type == 'bing'
23 changes: 23 additions & 0 deletions geoengine_bing/geo_view/geo_raster_layer_view.xml
@@ -0,0 +1,23 @@
<?xml version="1.0" encoding="UTF-8"?>

<odoo>

<record id="geo_raster_view_form" model="ir.ui.view">
<field name="name">geoengine.raster.layer.form</field>
<field name="model">geoengine.raster.layer</field>
<field name="inherit_id" ref="base_geoengine.geo_raster_view_form" />
<field name="arch" type="xml">
<xpath expr="//field[@name='is_wmts']" position="after">
<field name="is_bing" invisible="1"/>
</xpath>
<xpath expr="//field[@name='url']" position="after">
<field name="bing_key" colspan="4" attrs="{'required': [('is_bing', '=', True)], 'invisible': [('is_bing', '=', False)]}"/>
<field name="bing_imagery_set" colspan="4" attrs="{'required': [('is_bing', '=', True)], 'invisible': [('is_bing', '=', False)]}"/>
</xpath>
<xpath expr="//field[@name='url']" position="attributes">
<attribute name="attrs">{'required': [('is_wmts', '=', True)], 'invisible': [('is_bing', '=', True)]}</attribute>
</xpath>
</field>
</record>

</odoo>
25 changes: 25 additions & 0 deletions geoengine_bing/static/src/js/geoengine_common.js
@@ -0,0 +1,25 @@
odoo.define('geoengine_bing.BackgroundLayers', function (require) {
"use strict";

var BackgroundLayers = require('base_geoengine.BackgroundLayers');

BackgroundLayers.include({
handleCustomLayers: function (layer) {
var out = this._super.apply(this, arguments);
if (layer.is_bing) {
var layer_opt = {
title: layer.name,
visible: !layer.overlay,
type: 'base',
source: new ol.source.BingMaps({
layer: layer.name,
key: layer.bing_key,
imagerySet: layer.bing_imagery_set,
}),
};
out.push(new ol.layer.Tile(layer_opt));
}
return out;
},
});
});
11 changes: 11 additions & 0 deletions geoengine_bing/views/geoengine_bing_view.xml
@@ -0,0 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>

<odoo>

<template id="assets_backend" inherit_id="web.assets_backend">
<xpath expr="//script[last()]" position="after">
<script type="text/javascript" src="/geoengine_bing/static/src/js/geoengine_common.js" />
</xpath>
</template>

</odoo>

0 comments on commit 311185e

Please sign in to comment.