updates to generation

This commit is contained in:
Lucas Bradford 2019-04-27 15:25:32 +01:00
parent edb0cb820d
commit 11fff6ff2d

View file

@ -77,11 +77,11 @@ const natural_types =
burgs_groups = [ burgs_groups = [
{ type: "city", pop: 100000 }, { type: "city", pop: 100000, admin_level:8},
{ type: "town", pop: 2000 }, { type: "town", pop: 2000, admin_level:9},
{ type: "village", pop: 100 }, { type: "village", pop: 100, admin_level:10},
{ type: "hamlet", pop: 10 }, { type: "hamlet", pop: 10, admin_level:11},
{ type: "isolated_dwelling", pop: -1 } { type: "isolated_dwelling", pop: -1, admin_level:11}
] ]
numRegExp = new RegExp("[0-9]+"); numRegExp = new RegExp("[0-9]+");
@ -131,6 +131,7 @@ function dataget_settlements() {
for (let i = 0, c = 0; i < pack.burgs.length; i++) { for (let i = 0, c = 0; i < pack.burgs.length; i++) {
let burg = pack.burgs[i]; let burg = pack.burgs[i];
let type = ""; let type = "";
let level = "";
if ("i" in burg) { if ("i" in burg) {
settlements[c] = burg; settlements[c] = burg;
//replace population with actual value, scale * 1000 //replace population with actual value, scale * 1000
@ -139,10 +140,12 @@ function dataget_settlements() {
for (let t = 0; t < burgs_groups.length; t++) { for (let t = 0; t < burgs_groups.length; t++) {
if (pop > burgs_groups[t].pop) { if (pop > burgs_groups[t].pop) {
type = burgs_groups[t].type; type = burgs_groups[t].type;
level = burgs_groups[t].admin_level;
break; break;
} }
} }
settlements[c].type = type; settlements[c].type = type;
settlements[c].admin_level = level;
burgs_groups burgs_groups
c++; c++;
} }
@ -287,7 +290,7 @@ function osm_settlements_to_features(data, id, scale) {
nodes += latlongs_to_nodes(boundry, id); nodes += latlongs_to_nodes(boundry, id);
id += boundry.length + 1; id += boundry.length + 1;
tagcats = { tagcats = {
type: "boundry", boundary: "administrative", admin_level: "6", type: "boundry", boundary: "administrative", admin_level: data[i].admin_level,
name: data[i].name name: data[i].name
}; };
tags = gen_tags(tagcats); tags = gen_tags(tagcats);
@ -307,7 +310,7 @@ function osm_settlements_to_features(data, id, scale) {
id++; id++;
tagcats = { tagcats = {
type: "boundry", boundary: "administrative", border_type: "city", admin_level: "6", designation: "principal_area", type: "boundry", boundary: "administrative", border_type: "city", admin_level: data[i].admin_level, designation: "principal_area",
name: data[i].name, long_name: data[i].long_name, "is_in:country": data[i].country, "is_in:country_code": data[i].country_code, name: data[i].name, long_name: data[i].long_name, "is_in:country": data[i].country, "is_in:country_code": data[i].country_code,
cell: data[i].cell, region: data[i].region, area: (Math.PI * data.population ^ 2), culture: data[i].culture, cell: data[i].cell, region: data[i].region, area: (Math.PI * data.population ^ 2), culture: data[i].culture,
population: data[i].population, feature: data[i].feature, population: data[i].population, feature: data[i].feature,
@ -335,8 +338,8 @@ function osm_states_to_features(data, id, scale) {
start_id = id; start_id = id;
tagcats = { tagcats = {
type: "place", place: "region", region_id: b, border_type: "nation",
region_id: b boundary: "administrative", admin_level: "2",
}; };
let region_tags = gen_tags(tagcats); let region_tags = gen_tags(tagcats);
nodes += latlongs_to_nodes(xypath_to_latlong(boundries[b], scale), id); nodes += latlongs_to_nodes(xypath_to_latlong(boundries[b], scale), id);
@ -348,26 +351,31 @@ function osm_states_to_features(data, id, scale) {
if (data[i].center) { if (data[i].center) {
id++; id++;
tagcats = { tagcats = {
type: "place", place: "country", name: data[i].name, type: "place", place: "country", name: data[i].name,long_name: data[i].long_name,
cell: data[i].cell, region: data[i].region, area: (Math.PI * data.population ^ 2), culture: data[i].culture, cell: data[i].cell, region: data[i].region, culture: data[i].culture,
x: data[i].x, y: data[i].y, center: data[i].center, state_id: data[i].i x: data[i].x, y: data[i].y, center: data[i].center, country: data[i].name, country_code: data[i].i,
state_id: data[i].i, color: data[i].color, expansionism: data[i].expansionism, capital: data[i].capital,
state_type: data[i].type, center: data[i].center, culture: data[i].culture, cells: data[i].cells, area: data[i].area,
rural: data[i].rural, urban: data[i].urban, cities: data[i].burgs, x: data[i].x, y: data[i].y
}; };
tags = gen_tags(tagcats); tags = gen_tags(tagcats);
nodes += latlong_to_node(xy_to_coords(data[i].x * scale, data[i].y * scale), id, tags); nodes += latlong_to_node(xy_to_coords(data[i].x * scale, data[i].y * scale), id, tags);
members.push({ id: id, type: "node", role: "admin_centre" }); members.push({ id: id, type: "node", role: "label" });
id++; id++;
} }
tagcats = { tagcats = {
type: "multipolygon", boundary: "administrative", border_type: "city", admin_level: "6", designation: "principal_area", type: "boundary", boundary: "administrative", admin_level: "2",
name: data[i].name, long_name: data[i].long_name, "country": data[i].name, "country_code": data[i].i, border_type: "country", maritime: "yes",
name: data[i].name,long_name: data[i].long_name,
cell: data[i].cell, region: data[i].region, culture: data[i].culture,
x: data[i].x, y: data[i].y, center: data[i].center, country: data[i].name, country_code: data[i].i,
state_id: data[i].i, color: data[i].color, expansionism: data[i].expansionism, capital: data[i].capital, state_id: data[i].i, color: data[i].color, expansionism: data[i].expansionism, capital: data[i].capital,
state_type: data[i].type, center: data[i].center, culture: data[i].culture, cells: data[i].cells, area: data[i].area, state_type: data[i].type, center: data[i].center, culture: data[i].culture, cells: data[i].cells, area: data[i].area,
rural: data[i].rural, urban: data[i].urban, cities: data[i].burgs, x: data[i].x, y: data[i].y rural: data[i].rural, urban: data[i].urban, cities: data[i].burgs, x: data[i].x, y: data[i].y
}; };
tags = gen_tags(tagcats); tags = gen_tags(tagcats);
relations += gen_relation(id++, tags, members) relations += gen_relation(id++, tags, members);
} }
return { nodes: nodes, ways: ways, relations: relations, last_id: id }; return { nodes: nodes, ways: ways, relations: relations, last_id: id };
@ -392,7 +400,8 @@ function osm_coastlines_to_features(data, id, scale) {
ways += gen_way(id, start_id, boundry.length, tags); ways += gen_way(id, start_id, boundry.length, tags);
members.push({ id: id, type: "way", role: "outer" }); members.push({ id: id, type: "way", role: "outer" });
id++ id++
let type = natural_types.land.area[Math.floor((Math.random() * natural_types.land.area.length))]; //let type = natural_types.land.area[Math.floor((Math.random() * natural_types.land.area.length))];
let type = natural_types.land.area[4];
tagcats = { tagcats = {
type: "natural", natural: type, feature_id: data[i].i type: "natural", natural: type, feature_id: data[i].i
}; };
@ -422,6 +431,7 @@ function osm_lakes_to_features(data, id, scale) {
let relations = ""; let relations = "";
let tagcats = {}; let tagcats = {};
for (let i = 0; i < data.length; i++) { for (let i = 0; i < data.length; i++) {
let members = [];
id++; id++;
boundry = xypath_to_latlong(flatten_svg(data[i].path, 1000), scale); boundry = xypath_to_latlong(flatten_svg(data[i].path, 1000), scale);
start_id = id; start_id = id;
@ -430,6 +440,17 @@ function osm_lakes_to_features(data, id, scale) {
let name = type_names[data[i].group][i]; let name = type_names[data[i].group][i];
tagcats = { tagcats = {
type: "natural", natural: "water", water: "lake", type: "natural", natural: "water", water: "lake",
name: name
};
if (data.group === "salt") {
tagcats.salt = "yes";
}
tags = gen_tags(tagcats);
ways += gen_way(id, start_id, boundry.length, tags);
members.push({ id: id, type: "way", role: "outer" });
id++;
tagcats = {
type: "multipolygon", natural: "water", water: "lake",
name: name, body: data[i].body, border: data[i].border, name: name, body: data[i].body, border: data[i].border,
cells: data[i].cells, land: data[i].land, mtype: data[i].mtype, cells: data[i].cells, land: data[i].land, mtype: data[i].mtype,
feature_id: data[i].i feature_id: data[i].i
@ -438,8 +459,7 @@ function osm_lakes_to_features(data, id, scale) {
tagcats.salt = "yes"; tagcats.salt = "yes";
} }
tags = gen_tags(tagcats); tags = gen_tags(tagcats);
ways += gen_way(id, start_id, boundry.length, tags); relations += gen_relation(id++, tags, members);
id++;
} }
return { nodes: nodes, ways: ways, relations: relations, last_id: id }; return { nodes: nodes, ways: ways, relations: relations, last_id: id };
} }