Skip to content
/ osm Public
forked from CupIvan/osm

Commit

Permalink
СНТ - правка названия сразу в JOSM
Browse files Browse the repository at this point in the history
  • Loading branch information
CupIvan committed Mar 20, 2019
1 parent 19c78e4 commit 857ec08
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 13 deletions.
25 changes: 17 additions & 8 deletions allotments/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -33,15 +33,15 @@
var map = map.init()

/** содержимое popup на здании */
function make_popup(a)
function make_popup(a, marker)
{
var x, st = ''

if (a.tags[x='official_short_type'])
st += '<b>'+a.tags[x]+'</b> '

if (a.tags[x='name'])
st += '<b>'+(st?'"':'')+a.tags[x]+(st?'"':'')+'</b><br>'
if (a.tags['name'])
{
if (a.tags[x='official_short_type']) st += '<b>'+a.tags[x]+'</b> '
st += '<b>'+(st?'«':'')+a.tags['name']+(st?'»':'')+'</b><br>'
}

if (a.tags[x='error'])
st += '<b style="color: red">'+a.tags[x]+'</b><br>'
Expand All @@ -55,7 +55,16 @@
if (a.tags[x='contact:website'])
st += 'Сайт: <a href="'+a.tags[x]+'" target="_blank">'+a.tags[x]+'</a><br>'

st += osm.editLinks(a)
var re, params = null
if (re = /^([А-Я]+|с\/т) /.exec(a.tags.name))
{
var t = re[1]; if (t == 'с/т') t = 'СТ'
var name = a.tags.name.replace(t, '').replace(/^\s+|\s+$/g, '').replace(/^["«']|["»']$/g, '')
params = {official_short_type: t, name: name}
params.onedit = function(){ marker.setRadius(3) }
}

st += osm.editLinks(a, params)

return st;
}
Expand All @@ -77,7 +86,7 @@
if (!a.tags.name)
{ color = 'yellow'; a.tags.warning += 'Садовое товарищество без названия<br>'; }
else
if (re = /^([А-Я]+) /.exec(a.tags.name))
if (re = /^([А-Я]+|с\/т) /.exec(a.tags.name))
{ color = 'red'; a.tags.warning += 'В названии пишите только имя, тип укажите в теге <i>official_short_type='+re[1]+'</i><br>'; }
else
if (a.tags.name.indexOf('"') != -1 ||
Expand Down
12 changes: 11 additions & 1 deletion i/josm.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,16 @@ var josm = {
if (!type) type = osm.getType(a.id)
return 'http://127.0.0.1:8111/load_object?objects='+type[0]+a.id
},
// https://josm.openstreetmap.de/wiki/Help/RemoteControlCommands
/** ссылка на изменение параметров */
link_edit: function(a, params)
{
var type = a.type
if (!type) type = osm.getType(a.id)
var i, tags = ''
for (i in params) tags += (tags?'%7C':'')+i+'='+encodeURIComponent(params[i])
return 'http://127.0.0.1:8111/load_object?objects='+type[0]+a.id+'&addtags='+tags
},
}

/** проверка запущен JOSM или нет */
Expand All @@ -39,7 +49,7 @@ setInterval(x=function(){
}
})
}, 10000)
x()
setTimeout(x, 2000)

window.$(function() {
var div = document.createElement('div')
Expand Down
2 changes: 1 addition & 1 deletion i/map.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ init: function(params){
maxNativeZoom: 18,
}).addTo(map)

map.on('popupopen', function(e){ if (window.make_popup != undefined) e.popup.setContent(window.make_popup(e.popup.options.data)) })
map.on('popupopen', function(e){ if (window.make_popup != undefined) e.popup.setContent(window.make_popup(e.popup.options.data, e.popup._source)) })

map.on('moveend', function(){
var hash = '?z='+map.getZoom()
Expand Down
18 changes: 15 additions & 3 deletions i/osm.js
Original file line number Diff line number Diff line change
Expand Up @@ -198,15 +198,27 @@ getType: function(id)
},

/** ссылки на редактирование */
editLinks: function(a)
editLinks: function(a, params)
{
var st = ''
st +='<hr><small>'
st += '<a target="_blank" href="'+osm.link(a.id, a.type)+'">Открыть в OSM</a>'
if (josm.running)
st += '   <a target="josm" href="'+josm.link(a)+'">Загрузить в JOSM</a>'
{
st += '   <a target="josm" href="'+josm.link(a)+'">Загрузить в JOSM</a>'
if (params)
{
if (params.onedit) this.onedit = params.onedit
delete params.onedit
st += ' (<a target="josm" href="'+josm.link_edit(a, params)+'" onclick="osm.onEdit()">Правка</a>)'
}
}
st += '   <a target="_blank" href="http://level0.osmz.ru/?url='+a.type+'/'+a.id+'">Открыть в level0</a>'
return st
}
},
onEdit: function()
{
this.onedit()
},

}

0 comments on commit 857ec08

Please sign in to comment.