Skip to content

Commit

Permalink
Merge pull request #19 from ppKrauss/master
Browse files Browse the repository at this point in the history
show point on load, an issue #12 item
  • Loading branch information
ppKrauss authored Jan 10, 2019
2 parents 5b15708 + c955d28 commit 218cbdc
Show file tree
Hide file tree
Showing 7 changed files with 36 additions and 15 deletions.
40 changes: 26 additions & 14 deletions site3/assets/domPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,8 @@ function setRefPoint(lat, lon) {
$('#dom_base4').text(Geocode.hash_base4h);
$('#dom_geocode').val(showHash);
$('#dom_geocode_digits').html(Geocode.hash.length);
if (COVER.cover_rgxMcl && (t = Geocode.hash_base4h.match(COVER.cover_rgxMcl))) {
if (COVER.cover_rgxMcl && (!Geocode.cf_isoOnlyFor32 || Geocode.kx_hash_base==32)
&& (t = Geocode.hash_base4h.match(COVER.cover_rgxMcl))) {
//console.log("t=",t," of ",COVER.IdxOf)
if (Geocode.hash_base4h<15) $('#cell_etc').text('(inválido)')
else {
Expand Down Expand Up @@ -146,35 +147,46 @@ function getFromUrl() { // parse URL, get parameters
// e.g. #6gzm/sp-mtl , #6gycf/sp-spa or #6gkz/pr-cur
if ( m = UrlRequest.match(/^#geo:(\-?\d+\.\d+,\-?\d+\.\d+)$/) )
ret = {geo:m[1]};
else if ( m = UrlRequest.match(/^#([a-z0-9\+ ]+)[\/\-:;]+(.+)$/) )
else if ( m = UrlRequest.match(/^#([a-z0-9\+ ]+)[\/\-:;]+(.+)$/i) )
ret = {geocode:m[1],city:m[2]};
else if ( m = UrlRequest.match(/^#([A-Z][a-z0-9A-Z\-\.\+ ]+)[\/\-:;]+([a-z0-9]+)$/) )
ret = {geocode:m[2],city:m[1]};
else if ( m = UrlRequest.match(/^#([a-z0-9\+ ]+)$/) )
else if ( m = UrlRequest.match(/^#([a-z0-9\+ ]+)$/i) )
ret = {geocode:m[1]};
return ret;
} // \func

function runRequest() {
function runRequest(reqDefault={geo:"-23.550375,-46.633937",geo_level:20,city:"BR-SP-SPA"}
) {
var c = null,
r = getFromUrl();
if (!r) r = reqDefault;
if (r) { // check URL params
var used=false;
if ( r.geocode && (c = Geocode.setByHash_whenIsValid(r.geocode)) ) {
$('#dom_geocode').val(c.hash)
$('#dom_level').val(c.level)
setRefPoint(c.center);
used=true;
var ckeckCity = {"030333":"sp-spa", "030332":"pr-cur", "0313":"pa-atm"}; // revisar
var ckeckCity_rgx = /^(030333|030332|0313)/; // revisar
var ck = c.hash_base4h.match(ckeckCity_rgx);
if (ck) r.city=ckeckCity[ck[1]];
var hash = c.hash; // $('#dom_geocode').val(c.hash)
var level = c.level; // $('#dom_level').val(c.level)
c = c.center;
} else if (r.geo) {
$('#dom_level').val(15); // 1km
var c = Geocode.hlp_parseLatLon(r.geo);
setRefPoint(c);
used=true;
var level = r.geo_level? r.geo_level: 15;
//$('#dom_level').val(level); // 1km
c = Geocode.hlp_parseLatLon(r.geo);
}
//console.log("a",level,c);
if (r.city) {
console.log("debug1 city ok:",r)
//console.log("debug1 city ok:",r)
var city = r.city.replace(/^BR\-/i,'').toLowerCase();
cityCanvas.show(city); //,dom_id_ref,dom_class_selected)
cityCanvas.show(city,'city');
used=true;
}
if (c) {
//$('#dom_geocode').val(hash);
$('#dom_level').val(level);
setRefPoint(c);
used=true;
}
if (!used)
Expand Down
2 changes: 1 addition & 1 deletion site3/assets/lib_Geocode.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ var Geocode = {
,cf_halfDigit_2: '⬓' // down_black=2 or 3
,cf_hash_sep: '.' // standard is empty. Usual '.'
,cf_digSepRegex: /([^\+\-\.,;]{3})/g // f(alphabet,cf_hash_sep) usual or any other, for clean hash.

,cf_isoOnlyFor32: true
// CACHED-CONFIGS: obtained by method this.config() constructor
,kx_hash_baseAlphabet_case: 'lower'
,kx_hash_baseAlphabet: '0123456789bcdefghjkmnpqrstuvwxyz' // f(cf_hash_baseAlphabetLabel)
Expand Down
1 change: 1 addition & 0 deletions site3/assets/map.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ var cityCanvas = {
var jcity = $.ajax({ // see https://medium.com/d/c72ae3b41c01
url: cityCanvas.urlCities+fname+".geojson",
dataType: "json",
async: false, // MAU, usar https://api.jquery.com/jquery.deferred/ com opcao de day.
success: console.log(fname+" city successfully loaded."),
error: function(xhr) { alert(xhr.statusText); }
});
Expand Down
2 changes: 2 additions & 0 deletions site3/geohash-base16.htm
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@

<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel='shortcut icon' type='image/x-icon' href='./favicon.ico' />

<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/normalize.css"/>
<link rel="stylesheet" href="https://unpkg.com/[email protected]/dist/leaflet.css" crossorigin=""
integrity="sha512-puBpdR0798OZvTTbP4A8Ix/l+A4dHDD0DGqYW6RQ+9jxkRFclaxxQb/SJAWZfWAkuyeQUytO7+7N4QKrDh+drA=="
Expand Down
2 changes: 2 additions & 0 deletions site3/geohash-base32ghs.htm
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@

<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel='shortcut icon' type='image/x-icon' href='./favicon.ico' />

<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/normalize.css"/>
<link rel="stylesheet" href="https://unpkg.com/[email protected]/dist/leaflet.css" crossorigin=""
integrity="sha512-puBpdR0798OZvTTbP4A8Ix/l+A4dHDD0DGqYW6RQ+9jxkRFclaxxQb/SJAWZfWAkuyeQUytO7+7N4QKrDh+drA=="
Expand Down
2 changes: 2 additions & 0 deletions site3/geohash-base32pt.htm
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@

<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel='shortcut icon' type='image/x-icon' href='./favicon.ico' />

<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/normalize.css"/>
<link rel="stylesheet" href="https://unpkg.com/[email protected]/dist/leaflet.css" crossorigin=""
integrity="sha512-puBpdR0798OZvTTbP4A8Ix/l+A4dHDD0DGqYW6RQ+9jxkRFclaxxQb/SJAWZfWAkuyeQUytO7+7N4QKrDh+drA=="
Expand Down
2 changes: 2 additions & 0 deletions site3/geohash-base4h.htm
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@

<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel='shortcut icon' type='image/x-icon' href='./favicon.ico' />

<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/normalize.css"/>
<link rel="stylesheet" href="https://unpkg.com/[email protected]/dist/leaflet.css" crossorigin=""
integrity="sha512-puBpdR0798OZvTTbP4A8Ix/l+A4dHDD0DGqYW6RQ+9jxkRFclaxxQb/SJAWZfWAkuyeQUytO7+7N4QKrDh+drA=="
Expand Down

0 comments on commit 218cbdc

Please sign in to comment.