c80_map 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.gitignore +10 -0
- data/.travis.yml +3 -0
- data/CODE_OF_CONDUCT.md +13 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +21 -0
- data/README.md +51 -0
- data/Rakefile +1 -0
- data/app/admin/c80_map/settings.rb +32 -0
- data/app/assets/javascripts/buttons/admin_buttons/button_back_to_map.js +48 -0
- data/app/assets/javascripts/buttons/admin_buttons/button_cancel_create.js +21 -0
- data/app/assets/javascripts/buttons/admin_buttons/button_complete_create.js +22 -0
- data/app/assets/javascripts/buttons/admin_buttons/button_edit.js +80 -0
- data/app/assets/javascripts/buttons/admin_buttons/button_new.js +46 -0
- data/app/assets/javascripts/buttons/admin_buttons/button_save.js +83 -0
- data/app/assets/javascripts/buttons/zoom_buttons.js +61 -0
- data/app/assets/javascripts/c80_map.js.coffee +11 -0
- data/app/assets/javascripts/events/app_event.js +15 -0
- data/app/assets/javascripts/map_objects/area.js +221 -0
- data/app/assets/javascripts/map_objects/building.js +309 -0
- data/app/assets/javascripts/map_objects/dot.js +14 -0
- data/app/assets/javascripts/src/main.js +992 -0
- data/app/assets/javascripts/src/state_controller.js +220 -0
- data/app/assets/javascripts/src/utils.js +127 -0
- data/app/assets/javascripts/svg_elements/helper.js +36 -0
- data/app/assets/javascripts/svg_elements/polygon.js +192 -0
- data/app/assets/javascripts/view/save_preloader.js +30 -0
- data/app/assets/stylesheets/c80_map.scss +2 -0
- data/app/assets/stylesheets/map.scss +1435 -0
- data/app/assets/stylesheets/view/save_preloader.scss +206 -0
- data/app/controllers/c80_map/application_controller.rb +6 -0
- data/app/controllers/c80_map/map_ajax_controller.rb +54 -0
- data/app/helpers/c80_map/application_helper.rb +33 -0
- data/app/models/c80_map/area.rb +5 -0
- data/app/models/c80_map/building.rb +73 -0
- data/app/models/c80_map/setting.rb +30 -0
- data/app/uploaders/c80_map/map_image_uploader.rb +31 -0
- data/app/views/c80_map/_map_row.html.erb +15 -0
- data/app/views/c80_map/_map_row_index.html.erb +39 -0
- data/app/views/c80_map/shared/_save_preloader.html.erb +3 -0
- data/bin/console +14 -0
- data/bin/setup +7 -0
- data/c80_map.gemspec +25 -0
- data/config/routes.rb +3 -0
- data/db/migrate/20160617130000_create_c80_map_settings.rb +8 -0
- data/db/migrate/20160620040202_create_c80_map_areas.rb +9 -0
- data/db/migrate/20160620040204_create_c80_map_buildings.rb +8 -0
- data/db/seeds/801_fill_map_settings.rb +6 -0
- data/lib/c80_map/engine.rb +23 -0
- data/lib/c80_map/version.rb +3 -0
- data/lib/c80_map.rb +8 -0
- metadata +136 -0
| @@ -0,0 +1,221 @@ | |
| 1 | 
            +
            "use strict";
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            function Area() {
         | 
| 4 | 
            +
             | 
| 5 | 
            +
                var _map = null;
         | 
| 6 | 
            +
                var _this = this;
         | 
| 7 | 
            +
                //var _polygon = null;
         | 
| 8 | 
            +
                //var _polygon_overlay = null;
         | 
| 9 | 
            +
             | 
| 10 | 
            +
             | 
| 11 | 
            +
                // экранные координаты левой верхней точки, куда надо вписать полигон здания
         | 
| 12 | 
            +
                //var _left_page_x = 342;
         | 
| 13 | 
            +
                //var _left_page_y = 65;
         | 
| 14 | 
            +
             | 
| 15 | 
            +
                // bounding box полигона (в логических координатах)
         | 
| 16 | 
            +
                var _bbox = null;
         | 
| 17 | 
            +
             | 
| 18 | 
            +
                // центр полигона (в логических координатах)
         | 
| 19 | 
            +
                var _cx = null;
         | 
| 20 | 
            +
                var _cy = null;
         | 
| 21 | 
            +
             | 
| 22 | 
            +
                // если is_new, значит был полигон был
         | 
| 23 | 
            +
                // нарисован и ждёт сохранения на сервере
         | 
| 24 | 
            +
                //_this.is_new = false;
         | 
| 25 | 
            +
             | 
| 26 | 
            +
                _this.init = function (options, parent_building_hash, pself) {
         | 
| 27 | 
            +
                    clog("<Area.init>");
         | 
| 28 | 
            +
                    //clog(parent_building_hash); // => see building.js init comment
         | 
| 29 | 
            +
             | 
| 30 | 
            +
                    //clog(options);
         | 
| 31 | 
            +
                    /*{
         | 
| 32 | 
            +
                        "id": 1,
         | 
| 33 | 
            +
                        "object_type": "area",
         | 
| 34 | 
            +
                        "area_hash": {
         | 
| 35 | 
            +
                            "id": 2,
         | 
| 36 | 
            +
                            "title": "Площадь 2.12",
         | 
| 37 | 
            +
                            "is_free": false,
         | 
| 38 | 
            +
                            "props": {
         | 
| 39 | 
            +
                            "square": "100 кв.м.",
         | 
| 40 | 
            +
                            "floor_height": "6 кв. м",
         | 
| 41 | 
            +
                            "column_step": "2 м",
         | 
| 42 | 
            +
                            "gate_type": "распашные",
         | 
| 43 | 
            +
                            "communications": "Интернет, электричество, водоснабжение",
         | 
| 44 | 
            +
                            "price": "от 155 руб/кв.м в месяц"
         | 
| 45 | 
            +
                        }
         | 
| 46 | 
            +
                    },
         | 
| 47 | 
            +
                        "coords": [998.8649298732183,1717.326608643258,998.8649298732183,1717.326608643258,1230.8649298732184,1631.326608643258,1254.8649298732184,1663.326608643258,1160.8649298732184,1695.326608643258,1214.8649298732184,1803.326608643258,1066.8649298732184,1862.326608643258
         | 
| 48 | 
            +
                    ]
         | 
| 49 | 
            +
                    }*/
         | 
| 50 | 
            +
             | 
| 51 | 
            +
                    _map = pself;
         | 
| 52 | 
            +
                    _this._options = options;
         | 
| 53 | 
            +
             | 
| 54 | 
            +
                    // [4ddl5df]
         | 
| 55 | 
            +
                    if (_this._options["id"] == undefined) {
         | 
| 56 | 
            +
                        _this._options["id"] = Math.ceil((Math.random()*100000));
         | 
| 57 | 
            +
                    }
         | 
| 58 | 
            +
             | 
| 59 | 
            +
                    _this._options.parent_building_hash = parent_building_hash;
         | 
| 60 | 
            +
                    //clog(_this._options.parent_building_hash);
         | 
| 61 | 
            +
             | 
| 62 | 
            +
             | 
| 63 | 
            +
                    _this._polygon = Polygon.createFromSaved(options, false, _map);
         | 
| 64 | 
            +
                    _this._polygon.area = _this;
         | 
| 65 | 
            +
                    _this._polygon.parent_building_hash = parent_building_hash;
         | 
| 66 | 
            +
                    _this._polygon = $(_this._polygon.polygon);
         | 
| 67 | 
            +
             | 
| 68 | 
            +
             | 
| 69 | 
            +
                    _this._polygon_overlay = Polygon.createFromSaved(options, true, _map);
         | 
| 70 | 
            +
                    _this._polygon_overlay.area = _this;
         | 
| 71 | 
            +
                    _this._polygon_overlay = $(_this._polygon_overlay.polygon);
         | 
| 72 | 
            +
                    _this._polygon_overlay.hover(_this._mouse_in, _this._mouse_out);
         | 
| 73 | 
            +
                    _this._calcBBox();
         | 
| 74 | 
            +
             | 
| 75 | 
            +
                    var k = 'free';
         | 
| 76 | 
            +
                    if (options.area_hash != undefined) {
         | 
| 77 | 
            +
                        if (!options.area_hash.is_free) {
         | 
| 78 | 
            +
                            k = 'busy';
         | 
| 79 | 
            +
                        }
         | 
| 80 | 
            +
                    }
         | 
| 81 | 
            +
                    _this._polygon.parent().attr("class", k);
         | 
| 82 | 
            +
             | 
| 83 | 
            +
                };
         | 
| 84 | 
            +
             | 
| 85 | 
            +
                // optimisation
         | 
| 86 | 
            +
                var timeoutEnter = function () {
         | 
| 87 | 
            +
                    _map.showAreaInfo(_this._options.area_hash, _this._options.parent_building_hash);
         | 
| 88 | 
            +
                    _map.setMode('view_area');
         | 
| 89 | 
            +
                };
         | 
| 90 | 
            +
             | 
| 91 | 
            +
                _this.enter = function () {
         | 
| 92 | 
            +
                    //clog("<Building.enter>");
         | 
| 93 | 
            +
                    //clog(_this._options);
         | 
| 94 | 
            +
             | 
| 95 | 
            +
                    /* рассчитаем масштаб, при котором можно вписать прямоугольник дома в прямоугольник рабочей области */
         | 
| 96 | 
            +
             | 
| 97 | 
            +
                    var scaleX = _map.calcScale(_bbox.xmin, _bbox.xmax, _map.X1S, _map.X2S);
         | 
| 98 | 
            +
                    var scaleY = _map.calcScale(_bbox.ymin, _bbox.ymax, _map.Y1S, _map.Y2S);
         | 
| 99 | 
            +
                    var scale = (scaleX < scaleY) ? scaleX : scaleY;
         | 
| 100 | 
            +
                    _map.scale = scale;
         | 
| 101 | 
            +
             | 
| 102 | 
            +
                    // совмещаем точку на экране, в которую надо центрировать дома, с центром дома с учётом рассчитанного масштаба
         | 
| 103 | 
            +
                    _map.x = _map.normalizeX(_map.CX - _map.scale * _cx - _map.container.offset().left);
         | 
| 104 | 
            +
                    _map.y = _map.normalizeY(_map.CY - _map.scale * _cy - _map.container.offset().top);
         | 
| 105 | 
            +
             | 
| 106 | 
            +
                    clog("<Area.enter> [qq] moveTo: " + _map.x + ", " + _map.y);
         | 
| 107 | 
            +
                    clog("<Area.enter> Call moveTo.");
         | 
| 108 | 
            +
                    _map.moveTo(_map.x, _map.y, _map.scale, 400, 'easeInOutCubic');
         | 
| 109 | 
            +
             | 
| 110 | 
            +
                    setTimeout(timeoutEnter, 400);
         | 
| 111 | 
            +
             | 
| 112 | 
            +
                    var k;
         | 
| 113 | 
            +
                    if (_map.current_area != null) {
         | 
| 114 | 
            +
                        k = _map.current_area._polygon.parent().attr('class');
         | 
| 115 | 
            +
                        //clog("k = " + k);
         | 
| 116 | 
            +
                        k = k.split('viewing_area').join("");
         | 
| 117 | 
            +
                        _map.current_area._polygon.parent().attr("class", k);
         | 
| 118 | 
            +
                    }
         | 
| 119 | 
            +
             | 
| 120 | 
            +
                    k = _this._polygon.parent().attr("class");
         | 
| 121 | 
            +
                    k += " viewing_area";
         | 
| 122 | 
            +
                    _this._polygon.parent().attr("class", k);
         | 
| 123 | 
            +
             | 
| 124 | 
            +
                    _this.invalidateAnimationMask();
         | 
| 125 | 
            +
             | 
| 126 | 
            +
                    _map.current_area = _this;
         | 
| 127 | 
            +
                    _map.mark_virgin = false;
         | 
| 128 | 
            +
             | 
| 129 | 
            +
                };
         | 
| 130 | 
            +
             | 
| 131 | 
            +
                _this.exit = function () {
         | 
| 132 | 
            +
                    _map.current_area = null;
         | 
| 133 | 
            +
                };
         | 
| 134 | 
            +
             | 
| 135 | 
            +
                this.invalidateAnimationMask = function () {
         | 
| 136 | 
            +
                    $("#masked").attr('style', _this._calc_polygon_attr);
         | 
| 137 | 
            +
                };
         | 
| 138 | 
            +
             | 
| 139 | 
            +
                // выдать центр площади в логических координатах
         | 
| 140 | 
            +
                _this.cx = function () {
         | 
| 141 | 
            +
                    return _cx;
         | 
| 142 | 
            +
                };
         | 
| 143 | 
            +
                _this.cy = function () {
         | 
| 144 | 
            +
                    return _cy;
         | 
| 145 | 
            +
                };
         | 
| 146 | 
            +
             | 
| 147 | 
            +
                // рассчитаем bounding box полигона (в логических координатах)
         | 
| 148 | 
            +
                _this._calcBBox = function () {
         | 
| 149 | 
            +
             | 
| 150 | 
            +
                    var coords = _this._options.coords;
         | 
| 151 | 
            +
                    var xmin = Number.MAX_VALUE;
         | 
| 152 | 
            +
                    var ymin = Number.MAX_VALUE;
         | 
| 153 | 
            +
                    var xmax = Number.MIN_VALUE;
         | 
| 154 | 
            +
                    var ymax = Number.MIN_VALUE;
         | 
| 155 | 
            +
             | 
| 156 | 
            +
                    var ix, iy;
         | 
| 157 | 
            +
                    for (var i = 0, c = coords.length; i < c; i += 2) {
         | 
| 158 | 
            +
                        ix = coords[i];
         | 
| 159 | 
            +
                        iy = coords[i + 1];
         | 
| 160 | 
            +
             | 
| 161 | 
            +
                        //clog(xmin + " VS " + ix);
         | 
| 162 | 
            +
                        xmin = (ix < xmin) ? ix : xmin;
         | 
| 163 | 
            +
                        ymin = (iy < ymin) ? iy : ymin;
         | 
| 164 | 
            +
             | 
| 165 | 
            +
                        xmax = (ix > xmax) ? ix : xmax;
         | 
| 166 | 
            +
                        ymax = (iy > ymax) ? iy : ymax;
         | 
| 167 | 
            +
                    }
         | 
| 168 | 
            +
             | 
| 169 | 
            +
             | 
| 170 | 
            +
                    _bbox = {
         | 
| 171 | 
            +
                        xmin: xmin,
         | 
| 172 | 
            +
                        ymin: ymin,
         | 
| 173 | 
            +
                        xmax: xmax,
         | 
| 174 | 
            +
                        ymax: ymax
         | 
| 175 | 
            +
                    };
         | 
| 176 | 
            +
             | 
| 177 | 
            +
                    _cx = xmin + (xmax - xmin) / 2;
         | 
| 178 | 
            +
                    _cy = ymin + (ymax - ymin) / 2;
         | 
| 179 | 
            +
             | 
| 180 | 
            +
                    clog("<Area._calcBBox> " +
         | 
| 181 | 
            +
                        //xmin + "," + ymin + "; " + xmax + "," + ymax +
         | 
| 182 | 
            +
                    "; center logical: " + _cx + "," + _cy + ", center screen: " + _map.rightX(_cx) + ", " + _map.rightY(_cy));
         | 
| 183 | 
            +
                };
         | 
| 184 | 
            +
             | 
| 185 | 
            +
                _this._mouse_in = function () {
         | 
| 186 | 
            +
                    //clog('<Area._mouse_in>');
         | 
| 187 | 
            +
                    //clog(_this._polygon);
         | 
| 188 | 
            +
                    _this._polygon.attr('class', 'hover');
         | 
| 189 | 
            +
                };
         | 
| 190 | 
            +
             | 
| 191 | 
            +
                _this._mouse_out = function () {
         | 
| 192 | 
            +
                    //clog('<Area._mouse_out>');
         | 
| 193 | 
            +
                    _this._polygon.attr('class', '');
         | 
| 194 | 
            +
                };
         | 
| 195 | 
            +
             | 
| 196 | 
            +
                _this._calc_polygon_attr = function () {
         | 
| 197 | 
            +
                    var res = "";
         | 
| 198 | 
            +
             | 
| 199 | 
            +
                    var coords = _this._options["coords"];
         | 
| 200 | 
            +
                    var ix, iy;
         | 
| 201 | 
            +
                    for (var i = 0, c = coords.length; i < c; i += 2) {
         | 
| 202 | 
            +
                        ix = _map.scale * coords[i];
         | 
| 203 | 
            +
                        iy = _map.scale * coords[i + 1];
         | 
| 204 | 
            +
                        res += ix + "px " + iy + "px,"
         | 
| 205 | 
            +
                    }
         | 
| 206 | 
            +
             | 
| 207 | 
            +
                    //clog("<Area._calc_polygon_attr> res = " + res);
         | 
| 208 | 
            +
                    res = res.slice(0, res.length - 1);
         | 
| 209 | 
            +
                    res = "-webkit-clip-path:polygon(" + res + ")";
         | 
| 210 | 
            +
                    return res;
         | 
| 211 | 
            +
             | 
| 212 | 
            +
                }
         | 
| 213 | 
            +
             | 
| 214 | 
            +
                _this.to_json = function () {
         | 
| 215 | 
            +
                    return {
         | 
| 216 | 
            +
                        id:                 _this._options["id"],
         | 
| 217 | 
            +
                        coords:             _this._options["coords"],
         | 
| 218 | 
            +
                        parent_building_id: _this._options.parent_building_hash["id"]
         | 
| 219 | 
            +
                    }
         | 
| 220 | 
            +
                }
         | 
| 221 | 
            +
            }
         | 
| @@ -0,0 +1,309 @@ | |
| 1 | 
            +
            "use strict";
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            function Building() {
         | 
| 4 | 
            +
             | 
| 5 | 
            +
                var _map = null;
         | 
| 6 | 
            +
                var _this = this;
         | 
| 7 | 
            +
                var _options = null;
         | 
| 8 | 
            +
                var _polygon = null;
         | 
| 9 | 
            +
             | 
| 10 | 
            +
             | 
| 11 | 
            +
                // экранные координаты левой верхней точки, куда надо вписать полигон здания
         | 
| 12 | 
            +
                //var _left_page_x = 342;
         | 
| 13 | 
            +
                //var _left_page_y = 65;
         | 
| 14 | 
            +
             | 
| 15 | 
            +
                // bounding box полигона (в логических координатах)
         | 
| 16 | 
            +
                var _bbox = null;
         | 
| 17 | 
            +
             | 
| 18 | 
            +
                // центр полигона (в логических координатах)
         | 
| 19 | 
            +
                var _cx = null;
         | 
| 20 | 
            +
                var _cy = null;
         | 
| 21 | 
            +
             | 
| 22 | 
            +
                var _image_bg = null;
         | 
| 23 | 
            +
                var _image_overlay = null;
         | 
| 24 | 
            +
             | 
| 25 | 
            +
                var _zoomToMe = function () {
         | 
| 26 | 
            +
             | 
| 27 | 
            +
                    /* рассчитаем масштаб, при котором можно вписать прямоугольник дома в прямоугольник рабочей области */
         | 
| 28 | 
            +
             | 
| 29 | 
            +
                    var scaleX = _map.calcScale(_bbox.xmin, _bbox.xmax, _map.X1, _map.X2);
         | 
| 30 | 
            +
                    var scaleY = _map.calcScale(_bbox.ymin, _bbox.ymax, _map.Y1, _map.Y2);
         | 
| 31 | 
            +
                    //console.log("<Building.enter> scaleX = " + scaleX + ", scaleY = " + scaleY);
         | 
| 32 | 
            +
             | 
| 33 | 
            +
                    var scale = (scaleX < scaleY) ? scaleX : scaleY;
         | 
| 34 | 
            +
                    //var selfX = _map.calcCoord(scale, _map.X1, _bbox.xmin);
         | 
| 35 | 
            +
                    //var selfY = _map.calcCoord(scale, _map.Y1, _bbox.ymin);
         | 
| 36 | 
            +
             | 
| 37 | 
            +
                    _map.scale = scale;
         | 
| 38 | 
            +
                    //_map.x = selfX;
         | 
| 39 | 
            +
                    //_map.y = selfY;
         | 
| 40 | 
            +
             | 
| 41 | 
            +
                    /* по-отдельности */
         | 
| 42 | 
            +
             | 
| 43 | 
            +
                    //var scaleX = _map.calcScale(_bbox.xmin, _bbox.xmax, _map.X1, _map.X2);
         | 
| 44 | 
            +
                    //console.log("<Building.enter> scaleX = " + scaleX);
         | 
| 45 | 
            +
                    //var selfX = _map.calcCoord(scaleX, _map.X1, _bbox.xmin);
         | 
| 46 | 
            +
                    //_map.scale = scaleX;
         | 
| 47 | 
            +
                    //_map.x = selfX;
         | 
| 48 | 
            +
             | 
| 49 | 
            +
                    //var scaleY = _map.calcScale(_bbox.ymin, _bbox.ymax, _map.Y1, _map.Y2);
         | 
| 50 | 
            +
                    //console.log("<Building.enter> scaleY = " + scaleY);
         | 
| 51 | 
            +
                    //var selfY = _map.calcCoord(scaleY, _map.Y1, _bbox.ymin);
         | 
| 52 | 
            +
                    //_map.scale = scaleY;
         | 
| 53 | 
            +
                    //_map.y = selfY;
         | 
| 54 | 
            +
             | 
| 55 | 
            +
                    // совмещаем точку на экране, в которую надо центрировать дома, с центром дома с учётом рассчитанного масштаба
         | 
| 56 | 
            +
                    // или, другими словами, перегоняем логические координаты в систему координат экрана
         | 
| 57 | 
            +
                    _map.x = _map.normalizeX(_map.CX - _map.scale * _cx - _map.container.offset().left);
         | 
| 58 | 
            +
                    _map.y = _map.normalizeY(_map.CY - _map.scale * _cy - _map.container.offset().top);
         | 
| 59 | 
            +
             | 
| 60 | 
            +
                    //console.log("<Building.enter> [qq] moveTo: " + _map.x + ", " + _map.y);
         | 
| 61 | 
            +
                    _map.moveTo(_map.x, _map.y, _map.scale, 400, 'easeInOutCubic');
         | 
| 62 | 
            +
                };
         | 
| 63 | 
            +
             | 
| 64 | 
            +
                _this.init = function (options, link_to_map) {
         | 
| 65 | 
            +
                    console.log("<Building.init>");
         | 
| 66 | 
            +
             | 
| 67 | 
            +
                    //console.log(options);
         | 
| 68 | 
            +
                    /*
         | 
| 69 | 
            +
                            {
         | 
| 70 | 
            +
                                "object_type": "building",
         | 
| 71 | 
            +
                                "building_hash": {
         | 
| 72 | 
            +
                                "id": 2,
         | 
| 73 | 
            +
                                    "title": "Здание 2",
         | 
| 74 | 
            +
                                    "props": {
         | 
| 75 | 
            +
                                    "square": "1234 кв.м.",
         | 
| 76 | 
            +
                                        "square_free": "124 кв. м",
         | 
| 77 | 
            +
                                        "floor_height": "6 кв. м",
         | 
| 78 | 
            +
                                        "column_step": "2 м",
         | 
| 79 | 
            +
                                        "gate_type": "распашные",
         | 
| 80 | 
            +
                                        "communications": "Интернет, электричество, водоснабжение",
         | 
| 81 | 
            +
                                        "price": "от 155 руб/кв.м в месяц"
         | 
| 82 | 
            +
                                }
         | 
| 83 | 
            +
                            },
         | 
| 84 | 
            +
                                "img": {
         | 
| 85 | 
            +
                                "bg": {"src": "/assets/sample_bg-e36f4b42acde72d4ff05376498e5834423165d43e73650dd24a342ecb20779b9.gif"},
         | 
| 86 | 
            +
                                "overlay": {
         | 
| 87 | 
            +
                                    "type": "overlay",
         | 
| 88 | 
            +
                                        "src": "/assets/sample_overlay-f99419a8904207a6ac74288bccac16c76b388b7162bf2629a2a8dd825746f49b.gif"
         | 
| 89 | 
            +
                                }
         | 
| 90 | 
            +
                            },
         | 
| 91 | 
            +
                                "coords": [
         | 
| 92 | 
            +
                                986.2441809823903,1696.3649485107717,986.2441809823903,1696.3649485107717,1607.2441809823904,1459.3649485107717,1649.2441809823904,1510.3649485107717,1692.2441809823904,1597.3649485107717,1682.2441809823904,1602.3649485107717,1684.2441809823904,1617.3649485107717,1067.2441809823904,1863.3649485107717,1063.2441809823904,1844.3649485107717,1053.2441809823904,1852.3649485107717,1016.2441809823903,1755.3649485107717
         | 
| 93 | 
            +
                            ],
         | 
| 94 | 
            +
                                "props": {},
         | 
| 95 | 
            +
                                "childs": [
         | 
| 96 | 
            +
                                {
         | 
| 97 | 
            +
                                    "id": 1,
         | 
| 98 | 
            +
                                    "object_type": "area",
         | 
| 99 | 
            +
                                    "area_hash": {
         | 
| 100 | 
            +
                                        "id": 2,
         | 
| 101 | 
            +
                                        "title": "Площадь 2.12",
         | 
| 102 | 
            +
                                        "is_free": false,
         | 
| 103 | 
            +
                                        "props": {
         | 
| 104 | 
            +
                                            "square": "100 кв.м.",
         | 
| 105 | 
            +
                                            "floor_height": "6 кв. м",
         | 
| 106 | 
            +
                                            "column_step": "2 м",
         | 
| 107 | 
            +
                                            "gate_type": "распашные",
         | 
| 108 | 
            +
                                            "communications": "Интернет, электричество, водоснабжение",
         | 
| 109 | 
            +
                                            "price": "от 155 руб/кв.м в месяц"
         | 
| 110 | 
            +
                                        }
         | 
| 111 | 
            +
                                    },
         | 
| 112 | 
            +
                                    "coords": [
         | 
| 113 | 
            +
                                        998.8649298732183,1717.326608643258,998.8649298732183,1717.326608643258,1230.8649298732184,1631.326608643258,1254.8649298732184,1663.326608643258,1160.8649298732184,1695.326608643258,1214.8649298732184,1803.326608643258,1066.8649298732184,1862.326608643258
         | 
| 114 | 
            +
                                    ]
         | 
| 115 | 
            +
                                },
         | 
| 116 | 
            +
                                {
         | 
| 117 | 
            +
                                    "id": 2,
         | 
| 118 | 
            +
                                    "object_type": "area",
         | 
| 119 | 
            +
                                    "area_hash": {
         | 
| 120 | 
            +
                                        "id": 2,
         | 
| 121 | 
            +
                                        "title": "Площадь 2.13",
         | 
| 122 | 
            +
                                        "is_free": true,
         | 
| 123 | 
            +
                                        "props": {
         | 
| 124 | 
            +
                                            "square": "102 кв.м.",
         | 
| 125 | 
            +
                                            "floor_height": "6 кв. м",
         | 
| 126 | 
            +
                                            "column_step": "2 м",
         | 
| 127 | 
            +
                                            "gate_type": "распашные",
         | 
| 128 | 
            +
                                            "communications": "Интернет, электричество, водоснабжение",
         | 
| 129 | 
            +
                                            "price": "от 155 руб/кв.м в месяц"
         | 
| 130 | 
            +
                                        }
         | 
| 131 | 
            +
                                    },
         | 
| 132 | 
            +
                                    "coords": [
         | 
| 133 | 
            +
                                        1174.8649298732184,1726.326608643258,1160.8649298732184,1695.326608643258,1253.8649298732184,1664.326608643258,1290.8649298732184,1724.326608643258,1385.8649298732184,1683.326608643258,1408.8649298732184,1725.326608643258,1215.8649298732184,1804.326608643258
         | 
| 134 | 
            +
                                    ]
         | 
| 135 | 
            +
                                },
         | 
| 136 | 
            +
                                {
         | 
| 137 | 
            +
                                    "id": 3,
         | 
| 138 | 
            +
                                    "object_type": "area",
         | 
| 139 | 
            +
                                    "area_hash": {
         | 
| 140 | 
            +
                                        "id": 2,
         | 
| 141 | 
            +
                                        "title": "Площадь 2.15",
         | 
| 142 | 
            +
                                        "is_free": true,
         | 
| 143 | 
            +
                                        "props": {
         | 
| 144 | 
            +
                                            "square": "150 кв.м.",
         | 
| 145 | 
            +
                                            "floor_height": "6 кв. м",
         | 
| 146 | 
            +
                                            "column_step": "2 м",
         | 
| 147 | 
            +
                                            "gate_type": "распашные",
         | 
| 148 | 
            +
                                            "communications": "Интернет, электричество, водоснабжение",
         | 
| 149 | 
            +
                                            "price": "от 155 руб/кв.м в месяц"
         | 
| 150 | 
            +
                                        }
         | 
| 151 | 
            +
                                    },
         | 
| 152 | 
            +
                                    "coords": [
         | 
| 153 | 
            +
                                        1319.8649298732184,1597.326608643258,1230.8649298732184,1633.326608643258,1292.8649298732184,1723.326608643258,1384.8649298732184,1683.326608643258,1408.8649298732184,1726.326608643258,1510.8649298732184,1686.326608643258,1414.8649298732184,1561.326608643258
         | 
| 154 | 
            +
                                    ]
         | 
| 155 | 
            +
                                },
         | 
| 156 | 
            +
                                {
         | 
| 157 | 
            +
                                    "id": 4,
         | 
| 158 | 
            +
                                    "object_type": "area",
         | 
| 159 | 
            +
                                    "area_hash": {
         | 
| 160 | 
            +
                                        "id": 2,
         | 
| 161 | 
            +
                                        "title": "Площадь 2.12",
         | 
| 162 | 
            +
                                        "is_free": true,
         | 
| 163 | 
            +
                                        "props": {
         | 
| 164 | 
            +
                                            "square": "124 кв.м.",
         | 
| 165 | 
            +
                                            "floor_height": "6 кв. м",
         | 
| 166 | 
            +
                                            "column_step": "2 м",
         | 
| 167 | 
            +
                                            "gate_type": "распашные",
         | 
| 168 | 
            +
                                            "communications": "Интернет, электричество, водоснабжение",
         | 
| 169 | 
            +
                                            "price": "от 155 руб/кв.м в месяц"
         | 
| 170 | 
            +
                                        }
         | 
| 171 | 
            +
                                    },
         | 
| 172 | 
            +
                                    "coords": [
         | 
| 173 | 
            +
                                        1420.8649298732184,1558.326608643258,1415.8649298732184,1561.326608643258,1510.8649298732184,1686.326608643258,1570.8649298732184,1661.326608643258,1476.8649298732184,1537.326608643258
         | 
| 174 | 
            +
                                    ]
         | 
| 175 | 
            +
                                },
         | 
| 176 | 
            +
                                {
         | 
| 177 | 
            +
                                    "id": 4,
         | 
| 178 | 
            +
                                    "object_type": "area",
         | 
| 179 | 
            +
                                    "area_hash": {
         | 
| 180 | 
            +
                                        "id": 2,
         | 
| 181 | 
            +
                                        "title": "Площадь 2.12",
         | 
| 182 | 
            +
                                        "is_free": true,
         | 
| 183 | 
            +
                                        "props": {
         | 
| 184 | 
            +
                                            "square": "124 кв.м.",
         | 
| 185 | 
            +
                                            "floor_height": "6 кв. м",
         | 
| 186 | 
            +
                                            "column_step": "2 м",
         | 
| 187 | 
            +
                                            "gate_type": "распашные",
         | 
| 188 | 
            +
                                            "communications": "Интернет, электричество, водоснабжение",
         | 
| 189 | 
            +
                                            "price": "от 155 руб/кв.м в месяц"
         | 
| 190 | 
            +
                                        }
         | 
| 191 | 
            +
                                    },
         | 
| 192 | 
            +
                                    "coords": [
         | 
| 193 | 
            +
                                        1484.8649298732184,1533.326608643258,1476.8649298732184,1536.326608643258,1570.8649298732184,1661.326608643258,1681.8649298732184,1616.326608643258,1601.8649298732184,1486.326608643258
         | 
| 194 | 
            +
                                    ]
         | 
| 195 | 
            +
                                }
         | 
| 196 | 
            +
                            ],
         | 
| 197 | 
            +
                                "floors": []
         | 
| 198 | 
            +
                            }*/
         | 
| 199 | 
            +
             | 
| 200 | 
            +
                    _map = link_to_map;
         | 
| 201 | 
            +
                    _options = options;
         | 
| 202 | 
            +
                    _this.options = options;
         | 
| 203 | 
            +
             | 
| 204 | 
            +
                    // [4ddl5df]: в случае, если это только что отрисованное Здание - генерим временный случайный id
         | 
| 205 | 
            +
                    if (_this.options["id"] == undefined) {
         | 
| 206 | 
            +
                        _this.options["id"] = Math.ceil((Math.random()*100000));
         | 
| 207 | 
            +
                    }
         | 
| 208 | 
            +
             | 
| 209 | 
            +
                    _polygon = Polygon.createFromSaved(options, false, _map);
         | 
| 210 | 
            +
                    _polygon.building = _this;
         | 
| 211 | 
            +
             | 
| 212 | 
            +
                    _this._calcBBox();
         | 
| 213 | 
            +
                };
         | 
| 214 | 
            +
             | 
| 215 | 
            +
                _this.enter = function () {
         | 
| 216 | 
            +
                    //console.log("<Building.enter>");
         | 
| 217 | 
            +
                    //console.log(_options);
         | 
| 218 | 
            +
             | 
| 219 | 
            +
                    _zoomToMe();
         | 
| 220 | 
            +
             | 
| 221 | 
            +
             | 
| 222 | 
            +
                    setTimeout(function () {
         | 
| 223 | 
            +
                        _image_overlay = _map.draw_child_bg_image(_options.img.overlay.src, 'building', true);
         | 
| 224 | 
            +
                        _image_bg = _map.draw_child_bg_image(_options.img.bg.src, 'building');
         | 
| 225 | 
            +
                        _map.setMode('view_building');
         | 
| 226 | 
            +
                        _map.showBuildingInfo(_options.building_hash);
         | 
| 227 | 
            +
                        _map.draw_childs(_options.childs, _options.building_hash);
         | 
| 228 | 
            +
                    }, 400);
         | 
| 229 | 
            +
             | 
| 230 | 
            +
                    _map.svgRemoveAllNodes();
         | 
| 231 | 
            +
             | 
| 232 | 
            +
                    _map.current_building = _this;
         | 
| 233 | 
            +
                    _map.mark_virgin = false;
         | 
| 234 | 
            +
             | 
| 235 | 
            +
                };
         | 
| 236 | 
            +
             | 
| 237 | 
            +
                _this.exit = function () {
         | 
| 238 | 
            +
                    _image_bg.remove();
         | 
| 239 | 
            +
                    _image_overlay.remove();
         | 
| 240 | 
            +
                    _image_bg = null;
         | 
| 241 | 
            +
                    _image_overlay = null;
         | 
| 242 | 
            +
                    _zoomToMe();
         | 
| 243 | 
            +
                    _map.current_building = null;
         | 
| 244 | 
            +
                };
         | 
| 245 | 
            +
             | 
| 246 | 
            +
                // выдать центр дома в логических координатах
         | 
| 247 | 
            +
                _this.cx = function () {
         | 
| 248 | 
            +
                    return _cx;
         | 
| 249 | 
            +
                };
         | 
| 250 | 
            +
                _this.cy = function () {
         | 
| 251 | 
            +
                    return _cy;
         | 
| 252 | 
            +
                };
         | 
| 253 | 
            +
             | 
| 254 | 
            +
                // рассчитаем bounding box полигона (в логических координатах)
         | 
| 255 | 
            +
                _this._calcBBox = function () {
         | 
| 256 | 
            +
             | 
| 257 | 
            +
                    var coords = _options.coords;
         | 
| 258 | 
            +
                    var xmin = Number.MAX_VALUE;
         | 
| 259 | 
            +
                    var ymin = Number.MAX_VALUE;
         | 
| 260 | 
            +
                    var xmax = Number.MIN_VALUE;
         | 
| 261 | 
            +
                    var ymax = Number.MIN_VALUE;
         | 
| 262 | 
            +
             | 
| 263 | 
            +
                    var ix, iy;
         | 
| 264 | 
            +
                    for (var i = 0, c = coords.length; i < c; i += 2) {
         | 
| 265 | 
            +
                        ix = coords[i];
         | 
| 266 | 
            +
                        iy = coords[i + 1];
         | 
| 267 | 
            +
             | 
| 268 | 
            +
                        //console.log(xmin + " VS " + ix);
         | 
| 269 | 
            +
                        xmin = (ix < xmin) ? ix : xmin;
         | 
| 270 | 
            +
                        ymin = (iy < ymin) ? iy : ymin;
         | 
| 271 | 
            +
             | 
| 272 | 
            +
                        xmax = (ix > xmax) ? ix : xmax;
         | 
| 273 | 
            +
                        ymax = (iy > ymax) ? iy : ymax;
         | 
| 274 | 
            +
                    }
         | 
| 275 | 
            +
             | 
| 276 | 
            +
             | 
| 277 | 
            +
                    _bbox = {
         | 
| 278 | 
            +
                        xmin: xmin,
         | 
| 279 | 
            +
                        ymin: ymin,
         | 
| 280 | 
            +
                        xmax: xmax,
         | 
| 281 | 
            +
                        ymax: ymax
         | 
| 282 | 
            +
                    };
         | 
| 283 | 
            +
             | 
| 284 | 
            +
                    _cx = xmin + (xmax - xmin) / 2;
         | 
| 285 | 
            +
                    _cy = ymin + (ymax - ymin) / 2;
         | 
| 286 | 
            +
             | 
| 287 | 
            +
                    console.log("<Building._calcBBox> " +
         | 
| 288 | 
            +
                        //xmin + "," + ymin + "; " + xmax + "," + ymax +
         | 
| 289 | 
            +
                    "; center logical: " + _cx + "," + _cy + ", center screen: " + _map.rightX(_cx) + ", " + _map.rightY(_cy));
         | 
| 290 | 
            +
                };
         | 
| 291 | 
            +
             | 
| 292 | 
            +
                // при редактировании здания (т.е. изменении полигонов и holer-ов площадей)
         | 
| 293 | 
            +
                // необходимо, чтобы оверлейный слой с колоннами не мешал кликам мышки
         | 
| 294 | 
            +
                // добраться до слоя с svg
         | 
| 295 | 
            +
                // эти методы для этого имплементированы
         | 
| 296 | 
            +
                _this.changeOverlayZindex = function () {
         | 
| 297 | 
            +
                    _image_overlay.css('z-index','1');
         | 
| 298 | 
            +
                };
         | 
| 299 | 
            +
                _this.resetOverlayZindex = function () {
         | 
| 300 | 
            +
                    _image_overlay.css('z-index','3');
         | 
| 301 | 
            +
                };
         | 
| 302 | 
            +
             | 
| 303 | 
            +
                _this.to_json = function () {
         | 
| 304 | 
            +
                    return {
         | 
| 305 | 
            +
                        id:     _this.options["id"],
         | 
| 306 | 
            +
                        coords: _this.options["coords"]
         | 
| 307 | 
            +
                    }
         | 
| 308 | 
            +
                }
         | 
| 309 | 
            +
            }
         | 
| @@ -0,0 +1,14 @@ | |
| 1 | 
            +
             | 
| 2 | 
            +
            function Dot() {
         | 
| 3 | 
            +
             | 
| 4 | 
            +
                var _this = this;
         | 
| 5 | 
            +
                var _options = null;
         | 
| 6 | 
            +
                var _polygon = null;
         | 
| 7 | 
            +
             | 
| 8 | 
            +
                _this.init = function (options,pself) {
         | 
| 9 | 
            +
                    console.log('<Dot.init>');
         | 
| 10 | 
            +
                    _options = options;
         | 
| 11 | 
            +
                    _polygon = Polygon.createFromSaved(options, false, pself);
         | 
| 12 | 
            +
                }
         | 
| 13 | 
            +
             | 
| 14 | 
            +
            }
         |