Skip to content

Commit

Permalink
Merge branch 'main' into zlw-osmus-partner
Browse files Browse the repository at this point in the history
  • Loading branch information
ZeLonewolf authored Nov 30, 2024
2 parents 21d2e8c + 56cbdab commit 1d4115f
Show file tree
Hide file tree
Showing 11 changed files with 566 additions and 273 deletions.
4 changes: 4 additions & 0 deletions icons/poi_restaurant.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
53 changes: 49 additions & 4 deletions scripts/taginfo_template.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,31 +21,31 @@
"object_types": ["node"],
"description": "Marks the city with a national capital icon.",
"doc_url": "https://openmaptiles.org/schema/#capital",
"icon_url": "https://raw.githubusercontent.com/osm-americana/openstreetmap-americana/main/icons/star_nation_capital.svg"
"icon_url": "https://raw.githubusercontent.com/osm-americana/openstreetmap-americana/main/icons/place_star_in_circle.svg"
},
{
"key": "capital",
"value": "2",
"object_types": ["node"],
"description": "Marks the city with a national capital icon.",
"doc_url": "https://openmaptiles.org/schema/#capital",
"icon_url": "https://raw.githubusercontent.com/osm-americana/openstreetmap-americana/main/icons/star_nation_capital.svg"
"icon_url": "https://raw.githubusercontent.com/osm-americana/openstreetmap-americana/main/icons/place_star_in_circle.svg"
},
{
"key": "capital",
"value": "3",
"object_types": ["node"],
"description": "Marks the city with a state capital icon.",
"doc_url": "https://openmaptiles.org/schema/#capital",
"icon_url": "https://raw.githubusercontent.com/osm-americana/openstreetmap-americana/main/icons/star_state_capital.svg"
"icon_url": "https://raw.githubusercontent.com/osm-americana/openstreetmap-americana/main/icons/place_star.svg"
},
{
"key": "capital",
"value": "4",
"object_types": ["node"],
"description": "Marks the city with a state capital icon.",
"doc_url": "https://openmaptiles.org/schema/#capital",
"icon_url": "https://raw.githubusercontent.com/osm-americana/openstreetmap-americana/main/icons/star_state_capital.svg"
"icon_url": "https://raw.githubusercontent.com/osm-americana/openstreetmap-americana/main/icons/place_star.svg"
},
{
"key": "capital",
Expand Down Expand Up @@ -157,6 +157,27 @@
"doc_url": "https://openmaptiles.org/schema/#place",
"icon_url": "https://raw.githubusercontent.com/osm-americana/openstreetmap-americana/main/icons/place_dot.svg"
},
{
"key": "place",
"value": "suburb",
"object_types": ["node"],
"description": "Suburbs are labeled in capital letters.",
"doc_url": "https://openmaptiles.org/schema/#place"
},
{
"key": "place",
"value": "quarter",
"object_types": ["node"],
"description": "Quarters are labeled in capital letters.",
"doc_url": "https://openmaptiles.org/schema/#place"
},
{
"key": "place",
"value": "neighbourhood",
"object_types": ["node"],
"description": "Neighborhoods are labeled in capital letters.",
"doc_url": "https://openmaptiles.org/schema/#place"
},
{
"key": "disputed",
"value": "yes",
Expand Down Expand Up @@ -565,6 +586,30 @@
"doc_url": "https://openmaptiles.org/schema/#poi",
"icon_url": "https://raw.githubusercontent.com/osm-americana/openstreetmap-americana/main/icons/poi_martini_glass.svg"
},
{
"key": "amenity",
"value": "restaurant",
"object_types": ["node", "area"],
"description": "Restaurants are marked by an icon representing a knife and fork.",
"doc_url": "https://openmaptiles.org/schema/#poi",
"icon_url": "https://raw.githubusercontent.com/osm-americana/openstreetmap-americana/main/icons/poi_restaurant.svg"
},
{
"key": "amenity",
"value": "fast_food",
"object_types": ["node", "area"],
"description": "Restaurants are marked by an icon representing a knife and fork.",
"doc_url": "https://openmaptiles.org/schema/#poi",
"icon_url": "https://raw.githubusercontent.com/osm-americana/openstreetmap-americana/main/icons/poi_restaurant.svg"
},
{
"key": "amenity",
"value": "food_court",
"object_types": ["node", "area"],
"description": "Restaurants are marked by an icon representing a knife and fork.",
"doc_url": "https://openmaptiles.org/schema/#poi",
"icon_url": "https://raw.githubusercontent.com/osm-americana/openstreetmap-americana/main/icons/poi_restaurant.svg"
},
{
"key": "amenity",
"value": "hospital",
Expand Down
5 changes: 5 additions & 0 deletions shieldlib/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,10 @@ You should create one definition entry for each network. The entry key must matc
}
},
"banners": ["ALT"],
"bannerMap": {
"ThisNetwork:Truck": ["TRK"],
"ThisNetwork:Truck:Bypass": ["TRK", "BYP"]
},
"bannerTextColor": "#000",
"bannerTextHaloColor": "#FFF",
"textLayout": {
Expand Down Expand Up @@ -176,6 +180,7 @@ You should create one definition entry for each network. The entry key must matc

![Bannered routes near Downington, PA](https://wiki.openstreetmap.org/w/images/f/f8/Downington_bannered_routes_Americana.png)

- **`bannerMap`**: a map of network-to-banner arrays listing networks that should have the same style but with specified banners.
- **`bannerTextColor`**: specify the color of the banner text.
- **`bannerTextHaloColor`**: specify the color of the banner knockout halo.
- **`textLayout`**: specify how text should be inscribed within the padded bounds of the shield. The text will be drawn at the maximum size allowed by this constraint. See the [text layout functions](#text-layout-functions) section for text layout options.
Expand Down
2 changes: 1 addition & 1 deletion shieldlib/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@americana/maplibre-shield-generator",
"description": "Generate highway shields for maplibre-gl-js maps",
"version": "0.0.6",
"version": "0.0.7",
"author": "OpenStreetMap Americana Contributors",
"type": "module",
"keywords": [
Expand Down
25 changes: 25 additions & 0 deletions shieldlib/src/shield_renderer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import {
RouteDefinition,
RouteParser,
ShapeBlankParams,
ShieldDefinition,
ShieldDefinitions,
ShieldOptions,
ShieldSpecification,
Expand Down Expand Up @@ -104,6 +105,30 @@ export class AbstractShieldRenderer {
/** Specify which shields to draw and with what graphics */
protected setShields(shieldSpec: ShieldSpecification) {
this._renderContext.options = shieldSpec.options;

// Unpack any banner maps and compose them as separate network entries in-memory
for (const [key, shieldDef] of Object.entries(shieldSpec.networks)) {
if (!shieldDef) {
continue; // Skip if shieldDef is null or undefined
}

// Check to see if it has a bannerMap
if (shieldDef.bannerMap) {
// If it does, loop through each entry in the bannerMap
for (const [bannerKey, banners] of Object.entries(
shieldDef.bannerMap
)) {
// Make a copy of the ShieldDefinition and attach the banners
const banneredShieldDef: ShieldDefinition = {
...shieldDef,
banners: banners,
};
// Insert this modified ShieldDefinition into the global network list
shieldSpec.networks[bannerKey] = banneredShieldDef;
}
}
}

this._renderContext.shieldDef = shieldSpec.networks;
this._fontSpec = "1em " + shieldSpec.options.shieldFont;
console.log("ShieldJSON loaded");
Expand Down
4 changes: 4 additions & 0 deletions shieldlib/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,10 @@ export interface ShieldDefinitionBase {
textLayout?: TextLayout;
/** Banners to be drawn above a shield */
banners?: string[];
/** Map of additional networks that are bannered variants of this one */
bannerMap?: {
[key: string]: string[];
};
/** If true, no next should be drawn on this shield */
notext?: boolean;
/** Maximum size of shield text */
Expand Down
2 changes: 2 additions & 0 deletions src/constants/color.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ export const airportOutline = "hsl(250, 41%, 79%)";
export const airportRunway = "hsl(250, 41%, 79%)";
export const airportLabel = "hsl(250, 71%, 29%)";

export const urbanSubAreaLabel = "hsl(211, 43%, 28%)";

//TODO - rename this variable to "palette"
export const palette = {
black: "black",
Expand Down
Loading

0 comments on commit 1d4115f

Please sign in to comment.