Compare commits
6 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 81e02c670d | |||
| 3b4befb025 | |||
| 54d77ef09d | |||
| 82afafa294 | |||
| 90400d967f | |||
| 208df9e6af |
@@ -8,4 +8,4 @@ npx road-compiler --input /absolute/path/road-compiler.input.json
|
||||
|
||||
The compiler does not read host area configuration. The caller owns configuration normalization and creates the input JSON. Successful compilation writes exactly one `NATIVE_ROAD_COMPILE_DONE` JSON marker to stdout.
|
||||
|
||||
Run `npm test` and `npm run test:road-parity` after `npm ci` to validate the package without the host repository.
|
||||
Run `npm test` after `npm ci` to validate the package and its two self-contained area fixtures without the host repository. The migrated baselines remain upgrade corpus; the host repository owns the strict path-normalized parity gate.
|
||||
|
||||
24
assets/lane-icons/manifest.json
Normal file
@@ -0,0 +1,24 @@
|
||||
{
|
||||
"upstream": {
|
||||
"repository": "https://github.com/openstreetmap/lane-icons",
|
||||
"revision": "db3cab321da93a757c2cf3cdb4f1f1db6b1a091c",
|
||||
"license": "CC0-1.0",
|
||||
"license_file": "upstream/LICENSE.md"
|
||||
},
|
||||
"assets": [
|
||||
{"id":"through","source":"upstream/through.svg","anchor_x":12.5,"supported":true,"tested":true,"template":"through"},
|
||||
{"id":"left","source":"upstream/left.svg","anchor_x":17,"supported":true,"tested":true,"template":"left"},
|
||||
{"id":"right","source":"upstream/left.svg","derived_from":"left","mirror_x":true,"anchor_x":17,"supported":true,"tested":true,"template":"right"},
|
||||
{"id":"through;left","source":"upstream/left-through.svg","anchor_x":17,"supported":true,"tested":true,"template":"through_left"},
|
||||
{"id":"through;right","source":"upstream/left-through.svg","derived_from":"through;left","mirror_x":true,"anchor_x":17,"supported":true,"tested":true,"template":"through_right"},
|
||||
{"id":"through;left;right","source":"upstream/left-slight_left-through.svg","derived_from":"through;left + through;right","anchor_x":17,"supported":true,"tested":true,"template":"through_left_right"},
|
||||
{"id":"slight_left","source":"upstream/slight_left.svg","supported":false,"tested":false},
|
||||
{"id":"slight_left;through","source":"upstream/slight_left-through.svg","supported":false,"tested":false},
|
||||
{"id":"left;slight_left;through","source":"upstream/left-slight_left-through.svg","supported":false,"tested":false},
|
||||
{"id":"sharp_left","source":"upstream/sharp_left.svg","supported":false,"tested":false},
|
||||
{"id":"sharp_left;through","source":"upstream/sharp_left-through.svg","supported":false,"tested":false},
|
||||
{"id":"reverse_left","source":"upstream/reverse_left.svg","supported":false,"tested":false},
|
||||
{"id":"reverse_left;through","source":"upstream/reverse_left-through.svg","supported":false,"tested":false},
|
||||
{"id":"reverse_left;left;slight_left;through","source":"upstream/reverse_left-left-slight_left-through.svg","supported":false,"tested":false}
|
||||
]
|
||||
}
|
||||
98
assets/lane-icons/upstream/DESIGN.md
Normal file
@@ -0,0 +1,98 @@
|
||||
## Design Guidelines
|
||||
|
||||
The icons in this project follow closely the design guidelines established in the
|
||||
[MUTCD Standard Highway Signs guide](http://mutcd.fhwa.dot.gov/ser-shs_millennium.htm),
|
||||
2009 edition published by the US Federal Highway Administration.
|
||||
|
||||
The MUTCD is [in the public domain](http://mutcd.fhwa.dot.gov/knowledge/faqs/faq_general.htm#printq5)
|
||||
and as such it is not copyrighted.
|
||||
|
||||
Each icon should be
|
||||
|
||||
* 25px x 25px
|
||||
* SVG
|
||||
* Single color fill
|
||||
* Path outline only, no stroke
|
||||
* Pixel grid aligned (where possible)
|
||||
|
||||
### Arrows
|
||||
|
||||
Arrows use the "Standard Arrow" described in MUTCD Standard Highway Signs
|
||||
[Appendix](http://mutcd.fhwa.dot.gov/ser-shs_millennium.htm).
|
||||
|
||||
An upward facing Standard Arrow is included in this icon pack, and forms the basis of all turn
|
||||
lane arrows.
|
||||
|
||||
<img alt='Standard Arrow' width='300px' src='docs/standard_arrow.png'/>
|
||||
|
||||
|
||||
Arrowhead rotation angles are chosen based on the turn lane indication:
|
||||
|
||||
<table>
|
||||
<tr>
|
||||
<th>Through</th>
|
||||
<th>Slight Left</th>
|
||||
<th>Left</th>
|
||||
<th>Sharp Left</th>
|
||||
<th>Reverse Left</th>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>no rotation<br/>
|
||||
<img alt='Through' width='100px' src='https://cdn.rawgit.com/openstreetmap/lane-icons/master/docs/through.svg'/>
|
||||
</td>
|
||||
<td>45 degrees<br/>
|
||||
<img alt='Slight Left' width='100px' src='https://cdn.rawgit.com/openstreetmap/lane-icons/master/docs/slight_left.svg'/>
|
||||
</td>
|
||||
<td>70 or 90 degrees<br/>
|
||||
<img alt='Left' width='100px' src='https://cdn.rawgit.com/openstreetmap/lane-icons/master/docs/left.svg'/>
|
||||
</td>
|
||||
<td>135 degrees<br/>
|
||||
<img alt='Sharp Left' width='100px' src='https://cdn.rawgit.com/openstreetmap/lane-icons/master/docs/sharp_left.svg'/>
|
||||
</td>
|
||||
<td>180 degrees<br/>
|
||||
<img alt='Reverse Left' width='100px' src='https://cdn.rawgit.com/openstreetmap/lane-icons/master/docs/reverse_left.svg'/>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
As the number of arrows increases, the arrows scale down:
|
||||
|
||||
<table>
|
||||
<tr>
|
||||
<th>1 Arrow</th>
|
||||
<th>2 Arrows</th>
|
||||
<th>3 Arrows</th>
|
||||
<th>4 Arrows</th>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<ul><li>3px stroke</li><li>standard arrowhead</li></ul>
|
||||
<img alt='Through' width='100px' src='https://cdn.rawgit.com/openstreetmap/lane-icons/master/docs/through.svg'/>
|
||||
</td>
|
||||
<td>
|
||||
<ul><li>2.5px stroke</li><li>83% scaled arrowhead</li></ul>
|
||||
<img alt='Left, Through' width='100px' src='https://cdn.rawgit.com/openstreetmap/lane-icons/master/docs/left-through.svg'/>
|
||||
</td>
|
||||
<td>
|
||||
<ul><li>2.25px stroke</li><li>75% scaled arrowhead</li></ul>
|
||||
<img alt='Left, Slight Left, Through' width='100px' src='https://cdn.rawgit.com/openstreetmap/lane-icons/master/docs/left-slight_left-through.svg'/>
|
||||
</td>
|
||||
<td>
|
||||
<ul><li>2px stroke</li><li>66% scaled arrowhead</li></ul>
|
||||
<img alt='Reverse Left, Left, Slight Left, Through' width='100px' src='https://cdn.rawgit.com/openstreetmap/lane-icons/master/docs/reverse_left-left-slight_left-through.svg'/>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
|
||||
Other important rules for arrows:
|
||||
* Bottom aligned with each other, 2px from icon bottom edge
|
||||
* Left-right centered
|
||||
* Smooth curves, no kinks
|
||||
* Arrow shaft path connects to the arrowhead anchor point
|
||||
|
||||
|
||||
### Other Icons
|
||||
|
||||
Other non-arrow icons (bus, hov, pedestrian, tram, etc) also imitiate the icons found
|
||||
in the MUTCD Standard Highway Signs [Appendix](http://mutcd.fhwa.dot.gov/ser-shs_millennium.htm).
|
||||
118
assets/lane-icons/upstream/LICENSE.md
Normal file
@@ -0,0 +1,118 @@
|
||||
[](http://creativecommons.org/publicdomain/zero/1.0/)
|
||||
|
||||
### CC0 1.0 Universal
|
||||
|
||||
#### Statement of Purpose
|
||||
|
||||
The laws of most jurisdictions throughout the world automatically confer
|
||||
exclusive Copyright and Related Rights (defined below) upon the creator and
|
||||
subsequent owner(s) (each and all, an "owner") of an original work of
|
||||
authorship and/or a database (each, a "Work").
|
||||
|
||||
Certain owners wish to permanently relinquish those rights to a Work for the
|
||||
purpose of contributing to a commons of creative, cultural and scientific
|
||||
works ("Commons") that the public can reliably and without fear of later
|
||||
claims of infringement build upon, modify, incorporate in other works, reuse
|
||||
and redistribute as freely as possible in any form whatsoever and for any
|
||||
purposes, including without limitation commercial purposes. These owners may
|
||||
contribute to the Commons to promote the ideal of a free culture and the
|
||||
further production of creative, cultural and scientific works, or to gain
|
||||
reputation or greater distribution for their Work in part through the use and
|
||||
efforts of others.
|
||||
|
||||
For these and/or other purposes and motivations, and without any expectation
|
||||
of additional consideration or compensation, the person associating CC0 with a
|
||||
Work (the "Affirmer"), to the extent that he or she is an owner of Copyright
|
||||
and Related Rights in the Work, voluntarily elects to apply CC0 to the Work
|
||||
and publicly distribute the Work under its terms, with knowledge of his or her
|
||||
Copyright and Related Rights in the Work and the meaning and intended legal
|
||||
effect of CC0 on those rights.
|
||||
|
||||
**1. Copyright and Related Rights.** A Work made available under CC0 may be
|
||||
protected by copyright and related or neighboring rights ("Copyright and
|
||||
Related Rights"). Copyright and Related Rights include, but are not limited
|
||||
to, the following:
|
||||
|
||||
i. the right to reproduce, adapt, distribute, perform, display, communicate,
|
||||
and translate a Work;
|
||||
|
||||
ii. moral rights retained by the original author(s) and/or performer(s);
|
||||
|
||||
iii. publicity and privacy rights pertaining to a person's image or likeness
|
||||
depicted in a Work;
|
||||
|
||||
iv. rights protecting against unfair competition in regards to a Work,
|
||||
subject to the limitations in paragraph 4(a), below;
|
||||
|
||||
v. rights protecting the extraction, dissemination, use and reuse of data in
|
||||
a Work;
|
||||
|
||||
vi. database rights (such as those arising under Directive 96/9/EC of the
|
||||
European Parliament and of the Council of 11 March 1996 on the legal
|
||||
protection of databases, and under any national implementation thereof,
|
||||
including any amended or successor version of such directive); and
|
||||
|
||||
vii. other similar, equivalent or corresponding rights throughout the world
|
||||
based on applicable law or treaty, and any national implementations thereof.
|
||||
|
||||
**2. Waiver.** To the greatest extent permitted by, but not in contravention of,
|
||||
applicable law, Affirmer hereby overtly, fully, permanently, irrevocably and
|
||||
unconditionally waives, abandons, and surrenders all of Affirmer's Copyright
|
||||
and Related Rights and associated claims and causes of action, whether now
|
||||
known or unknown (including existing as well as future claims and causes of
|
||||
action), in the Work (i) in all territories worldwide, (ii) for the maximum
|
||||
duration provided by applicable law or treaty (including future time
|
||||
extensions), (iii) in any current or future medium and for any number of
|
||||
copies, and (iv) for any purpose whatsoever, including without limitation
|
||||
commercial, advertising or promotional purposes (the "Waiver"). Affirmer makes
|
||||
the Waiver for the benefit of each member of the public at large and to the
|
||||
detriment of Affirmer's heirs and successors, fully intending that such Waiver
|
||||
shall not be subject to revocation, rescission, cancellation, termination, or
|
||||
any other legal or equitable action to disrupt the quiet enjoyment of the Work
|
||||
by the public as contemplated by Affirmer's express Statement of Purpose.
|
||||
|
||||
**3. Public License Fallback.** Should any part of the Waiver for any reason be
|
||||
judged legally invalid or ineffective under applicable law, then the Waiver
|
||||
shall be preserved to the maximum extent permitted taking into account
|
||||
Affirmer's express Statement of Purpose. In addition, to the extent the Waiver
|
||||
is so judged Affirmer hereby grants to each affected person a royalty-free,
|
||||
non transferable, non sublicensable, non exclusive, irrevocable and
|
||||
unconditional license to exercise Affirmer's Copyright and Related Rights in
|
||||
the Work (i) in all territories worldwide, (ii) for the maximum duration
|
||||
provided by applicable law or treaty (including future time extensions), (iii)
|
||||
in any current or future medium and for any number of copies, and (iv) for any
|
||||
purpose whatsoever, including without limitation commercial, advertising or
|
||||
promotional purposes (the "License"). The License shall be deemed effective as
|
||||
of the date CC0 was applied by Affirmer to the Work. Should any part of the
|
||||
License for any reason be judged legally invalid or ineffective under
|
||||
applicable law, such partial invalidity or ineffectiveness shall not
|
||||
invalidate the remainder of the License, and in such case Affirmer hereby
|
||||
affirms that he or she will not (i) exercise any of his or her remaining
|
||||
Copyright and Related Rights in the Work or (ii) assert any associated claims
|
||||
and causes of action with respect to the Work, in either case contrary to
|
||||
Affirmer's express Statement of Purpose.
|
||||
|
||||
**4. Limitations and Disclaimers.**
|
||||
|
||||
a. No trademark or patent rights held by Affirmer are waived, abandoned,
|
||||
surrendered, licensed or otherwise affected by this document.
|
||||
|
||||
b. Affirmer offers the Work as-is and makes no representations or warranties
|
||||
of any kind concerning the Work, express, implied, statutory or otherwise,
|
||||
including without limitation warranties of title, merchantability, fitness
|
||||
for a particular purpose, non infringement, or the absence of latent or
|
||||
other defects, accuracy, or the present or absence of errors, whether or not
|
||||
discoverable, all to the greatest extent permissible under applicable law.
|
||||
|
||||
c. Affirmer disclaims responsibility for clearing rights of other persons
|
||||
that may apply to the Work or any use thereof, including without limitation
|
||||
any person's Copyright and Related Rights in the Work. Further, Affirmer
|
||||
disclaims responsibility for obtaining any necessary consents, permissions
|
||||
or other rights required for any use of the Work.
|
||||
|
||||
d. Affirmer understands and acknowledges that Creative Commons is not a
|
||||
party to this document and has no duty or obligation with respect to this
|
||||
CC0 or use of the Work.
|
||||
|
||||
For more information, please see
|
||||
<http://creativecommons.org/publicdomain/zero/1.0/>
|
||||
1
assets/lane-icons/upstream/left-slight_left-through.svg
Normal file
@@ -0,0 +1 @@
|
||||
<svg id="left-slight_left-through" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 25 25"><title>icons</title><line x1="18.1" y1="5.17" x2="18.11" y2="23" fill="none" stroke="#000" stroke-miterlimit="10" stroke-width="2.25"/><path d="M18.11,19.69c0-3.65-5.82-6.62-9.2-6.62" fill="none" stroke="#000" stroke-miterlimit="10" stroke-width="2.25"/><path d="M11.89,7.16S18.11,12.74,18.11,19" fill="none" stroke="#000" stroke-miterlimit="10" stroke-width="2.25"/><path d="M18.16,1.09a0.07,0.07,0,0,0-.12,0L15.26,5.36a0.42,0.42,0,0,0,.48.62l2.36-.81L20.47,6A0.42,0.42,0,0,0,21,5.37Z"/><path d="M4.83,13a0.07,0.07,0,0,0,0,.12L9.1,15.91a0.42,0.42,0,0,0,.62-0.48L8.91,13.07,9.72,10.7a0.42,0.42,0,0,0-.62-0.48Z"/><path d="M9.05,4.24A0.07,0.07,0,0,0,9,4.32l1,5a0.42,0.42,0,0,0,.78.1l1.1-2.24,2.25-1.1A0.42,0.42,0,0,0,14,5.28Z"/></svg>
|
||||
|
After Width: | Height: | Size: 822 B |
1
assets/lane-icons/upstream/left-through.svg
Normal file
@@ -0,0 +1 @@
|
||||
<svg id="left-through" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 25 25"><title>icons</title><line x1="17" y1="23" x2="17" y2="6.81" fill="none" stroke="#000" stroke-miterlimit="10" stroke-width="2.5"/><path d="M17,19c0-5.32-4.66-8.23-7.83-9.1" fill="none" stroke="#000" stroke-miterlimit="10" stroke-width="2.5"/><path d="M17.06,2.3a0.08,0.08,0,0,0-.13,0L13.85,7a0.47,0.47,0,0,0,.53.69L17,6.81l2.62,0.9A0.46,0.46,0,0,0,20.15,7Z"/><path d="M5,8.29a0.08,0.08,0,0,0,0,.12l3.38,4.51a0.47,0.47,0,0,0,.83-0.27L9.17,9.9l1.74-2.16A0.46,0.46,0,0,0,10.45,7Z"/></svg>
|
||||
|
After Width: | Height: | Size: 562 B |
1
assets/lane-icons/upstream/left.svg
Normal file
@@ -0,0 +1 @@
|
||||
<svg id="left" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 25 25"><title>icons</title><path d="M17,23V18c0-6.78-3.24-8.11-5.85-8.86" fill="none" stroke="#000" stroke-miterlimit="10" stroke-width="3"/><path d="M6.07,7.21A0.1,0.1,0,0,0,6,7.36l4.08,5.44a0.56,0.56,0,0,0,1-.32l0.06-3.33,2.1-2.6a0.56,0.56,0,0,0-.55-0.88Z"/></svg>
|
||||
|
After Width: | Height: | Size: 329 B |
@@ -0,0 +1 @@
|
||||
<svg id="reverse_left-left-slight_left-through" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 25 25"><title>icons</title><line x1="19" y1="4" x2="19" y2="23" fill="none" stroke="#000" stroke-miterlimit="10" stroke-width="2"/><path d="M7.21,12h5.5A15.61,15.61,0,0,1,19,13" fill="none" stroke="#000" stroke-miterlimit="10" stroke-width="2"/><path d="M13.7,5.85S19,9.23,19,15" fill="none" stroke="#000" stroke-miterlimit="10" stroke-width="2"/><path d="M19.05,0.43a0.07,0.07,0,0,0-.1,0L16.49,4.18a0.37,0.37,0,0,0,.42.55L19,4l2.09,0.71a0.37,0.37,0,0,0,.42-0.54Z"/><path d="M11.2,3.28a0.07,0.07,0,0,0-.07.07l0.92,4.39a0.37,0.37,0,0,0,.68.09l1-2,2-1A0.37,0.37,0,0,0,15.6,4.2Z"/><path d="M3.68,11.95a0.07,0.07,0,0,0,0,.1L7.44,14.5A0.37,0.37,0,0,0,8,14.08L7.21,12,8,9.91a0.37,0.37,0,0,0-.54-0.42Z"/><path d="M10,23.06a0.07,0.07,0,0,0,.1,0l2.45-3.76a0.37,0.37,0,0,0-.42-0.55L10,19.48l-2.09-.71a0.37,0.37,0,0,0-.42.54Z"/><path d="M19,16c0-5.42-9-4.84-9,0l0,3.48" fill="none" stroke="#000" stroke-miterlimit="10" stroke-width="2"/></svg>
|
||||
|
After Width: | Height: | Size: 1.0 KiB |
1
assets/lane-icons/upstream/reverse_left-through.svg
Normal file
@@ -0,0 +1 @@
|
||||
<svg id="reverse_left-through" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 25 25"><title>icons</title><path d="M8.36,23a0.08,0.08,0,0,0,.13,0l3.08-4.72A0.47,0.47,0,0,0,11,17.56l-2.62.9-2.62-.9a0.46,0.46,0,0,0-.53.68Z"/><line x1="17" y1="23.19" x2="17" y2="6.08" fill="none" stroke="#000" stroke-miterlimit="10" stroke-width="2.5"/><path d="M17.06,1.57a0.08,0.08,0,0,0-.13,0L13.85,6.29a0.47,0.47,0,0,0,.53.69L17,6.08,19.62,7a0.46,0.46,0,0,0,.53-0.68Z"/><path d="M17,16c0-5-8.58-5.08-8.58,0v2.46" fill="none" stroke="#000" stroke-miterlimit="10" stroke-width="2.5"/></svg>
|
||||
|
After Width: | Height: | Size: 574 B |
1
assets/lane-icons/upstream/reverse_left.svg
Normal file
@@ -0,0 +1 @@
|
||||
<svg id="reverse_left" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 25 25"><title>icons</title><path d="M7.8,23A0.1,0.1,0,0,0,8,23l3.72-5.69A0.56,0.56,0,0,0,11,16.45L7.88,17.53,4.72,16.44a0.56,0.56,0,0,0-.64.82Z"/><path d="M18,23V13c0-8-10.08-7.77-10.12.1v5.42" fill="none" stroke="#000" stroke-miterlimit="10" stroke-width="3"/></svg>
|
||||
|
After Width: | Height: | Size: 338 B |
1
assets/lane-icons/upstream/sharp_left-through.svg
Normal file
@@ -0,0 +1 @@
|
||||
<svg id="sharp_left-through" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 25 25"><title>icons</title><path d="M5.38,17.17a0.08,0.08,0,0,0,.09.09L11,16.1a0.47,0.47,0,0,0,.11-0.86L8.62,14,7.4,11.53a0.46,0.46,0,0,0-.86.11Z"/><line x1="17" y1="23.19" x2="17" y2="6.08" fill="none" stroke="#000" stroke-miterlimit="10" stroke-width="2.5"/><path d="M17.06,1.57a0.08,0.08,0,0,0-.13,0L13.85,6.29a0.47,0.47,0,0,0,.53.69L17,6.08,19.62,7a0.46,0.46,0,0,0,.53-0.68Z"/><path d="M17,15.65c0-4.75-5.12-5.25-8.38-1.63" fill="none" stroke="#000" stroke-miterlimit="10" stroke-width="2.5"/></svg>
|
||||
|
After Width: | Height: | Size: 580 B |
1
assets/lane-icons/upstream/sharp_left.svg
Normal file
@@ -0,0 +1 @@
|
||||
<svg id="sharp_left" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 25 25"><title>icons</title><path d="M4.1,15.8a0.1,0.1,0,0,0,.11.11l6.65-1.4a0.56,0.56,0,0,0,.13-1L8,12,6.53,9a0.56,0.56,0,0,0-1,.13Z"/><path d="M18,23V15c0-5.78-4-7.79-8.61-4.11L8,12" fill="none" stroke="#000" stroke-miterlimit="10" stroke-width="3"/></svg>
|
||||
|
After Width: | Height: | Size: 326 B |
1
assets/lane-icons/upstream/slight_left-through.svg
Normal file
@@ -0,0 +1 @@
|
||||
<svg id="slight_left-through" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 25 25"><title>icons</title><line x1="17" y1="23.19" x2="17" y2="6.08" fill="none" stroke="#000" stroke-miterlimit="10" stroke-width="2.5"/><path d="M17.06,1.57a0.08,0.08,0,0,0-.13,0L13.85,6.29a0.47,0.47,0,0,0,.53.69L17,6.08,19.62,7a0.46,0.46,0,0,0,.53-0.68Z"/><path d="M17,19c0-4.22-4.84-9.36-6.54-10.68" fill="none" stroke="#000" stroke-miterlimit="10" stroke-width="2.5"/><path d="M7.3,5.09a0.08,0.08,0,0,0-.09.09L8.37,10.7a0.47,0.47,0,0,0,.86.11l1.22-2.48,2.49-1.22a0.46,0.46,0,0,0-.11-0.86Z"/></svg>
|
||||
|
After Width: | Height: | Size: 581 B |
1
assets/lane-icons/upstream/slight_left.svg
Normal file
@@ -0,0 +1 @@
|
||||
<svg id="slight_left" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 25 25"><title>icons</title><path d="M15,23V20c0-4.12-.1-9.29-3-12.74" fill="none" stroke="#000" stroke-miterlimit="10" stroke-width="3"/><path d="M8.26,3.36a0.1,0.1,0,0,0-.11.11l1.4,6.65a0.56,0.56,0,0,0,1,.13l1.46-3,3-1.47a0.56,0.56,0,0,0-.13-1Z"/></svg>
|
||||
|
After Width: | Height: | Size: 324 B |
1
assets/lane-icons/upstream/through.svg
Normal file
@@ -0,0 +1 @@
|
||||
<svg id="through" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 25 25"><title>icons</title><line x1="12.5" y1="23" x2="12.5" y2="8.47" fill="none" stroke="#000" stroke-miterlimit="10" stroke-width="3"/><path d="M12.58,3a0.1,0.1,0,0,0-.16,0L8.7,8.73a0.56,0.56,0,0,0,.64.83L12.5,8.47l3.16,1.08a0.56,0.56,0,0,0,.64-0.82Z"/></svg>
|
||||
|
After Width: | Height: | Size: 328 B |
@@ -4,13 +4,17 @@
|
||||
const fs = require("fs");
|
||||
const path = require("path");
|
||||
const { compiler } = require("../src");
|
||||
const { exportNativeRoadPackage } = require("../src/export/native-road-package");
|
||||
|
||||
const args = process.argv.slice(2);
|
||||
const index = args.indexOf("--input");
|
||||
if (index < 0 || !args[index + 1] || index + 2 !== args.length) {
|
||||
throw new Error("Usage: road-compiler --input <RoadCompilerInput.json>");
|
||||
const exportIndex = args.indexOf("--export-zip");
|
||||
const expectedLength = exportIndex >= 0 ? 4 : 2;
|
||||
if (index < 0 || !args[index + 1] || (exportIndex >= 0 && !args[exportIndex + 1]) || args.length !== expectedLength) {
|
||||
throw new Error("Usage: road-compiler --input <RoadCompilerInput.json> [--export-zip <output.zip>]");
|
||||
}
|
||||
const inputFile = path.resolve(args[index + 1]);
|
||||
const input = JSON.parse(fs.readFileSync(inputFile, "utf8"));
|
||||
const { result, comparison } = compiler.compileInput(input);
|
||||
if (exportIndex >= 0) exportNativeRoadPackage(input.outDir, path.resolve(args[exportIndex + 1]));
|
||||
console.log(`NATIVE_ROAD_COMPILE_DONE ${JSON.stringify({ areaId: input.areaId, roads: result.model.roads.length, endpoints: result.model.endpoints.length, diagnostics: result.diagnostics.length, output: input.outDir, comparison })}`);
|
||||
|
||||
@@ -1,4 +1,8 @@
|
||||
# Native Road Package v1
|
||||
# Native Road Package v1.1
|
||||
|
||||
`native-road-package/v1.1` adds a required `manifest.json` to the v1 output.
|
||||
Consumers may ignore this file when reading legacy v1 packages, but v1.1
|
||||
consumers must validate and consume it.
|
||||
|
||||
`native-road-package/v1` defines the boundary between the host area pipeline
|
||||
and the native road compiler. The compiler accepts only the input below; it
|
||||
@@ -35,6 +39,12 @@ shape and owns all path derivation.
|
||||
|
||||
`outDir` contains these JSON documents:
|
||||
|
||||
- `manifest.json`: `{ contract: "native-road-package/v1.1", areaId, layers }`.
|
||||
`layers` declares exactly the twelve GeoJSON sources. Renderable entries have
|
||||
`role` (`surface` or `marking`) and `materialLayer`; semantic entries have
|
||||
`role: "semantic"` and no material. Optional `splitBy` contains one property
|
||||
and exact-match cases plus one default case.
|
||||
|
||||
- `compiled.json`: top-level keys are `schema`, `areaId`, `source`, `model`,
|
||||
`movements`, `trafficSignals`, `diagnostics`, and `layers`. `source` has
|
||||
`osm`, `overrides`, and `trafficSignals` paths.
|
||||
@@ -63,6 +73,20 @@ shape and owns all path derivation.
|
||||
The editable signal source at `trafficSignalsFile` is a sibling of `outDir`.
|
||||
It is included in the parity baseline because regeneration must be stable.
|
||||
|
||||
## ZIP Export
|
||||
|
||||
The Web workbench's **导出道路包** action and the CLI's optional
|
||||
`--export-zip <output.zip>` emit the portable package form. The ZIP root is
|
||||
flat: it contains the six JSON documents above and `layers/*.geojson`, without
|
||||
an enclosing area directory. It contains no OSM input, overrides, or compiler
|
||||
workspace paths. `compiled.json` retains only model and movement data needed by
|
||||
the downstream preview; its internal `source` paths are removed.
|
||||
|
||||
The ZIP manifest adds informational `generator: { name, version }`. Consumers
|
||||
must select compatibility only from `contract`, `areaId`, and declared files.
|
||||
Entry order and timestamp are fixed, so unchanged compiled output exports to
|
||||
the same ZIP hash.
|
||||
|
||||
Successful CLI execution prints exactly one completion marker:
|
||||
|
||||
```text
|
||||
|
||||
5
package-lock.json
generated
@@ -1,13 +1,14 @@
|
||||
{
|
||||
"name": "@osm-asset/road-compiler",
|
||||
"version": "0.1.0",
|
||||
"version": "0.2.2",
|
||||
"lockfileVersion": 3,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "@osm-asset/road-compiler",
|
||||
"version": "0.1.0",
|
||||
"version": "0.2.2",
|
||||
"dependencies": {
|
||||
"fflate": "0.8.3",
|
||||
"ol": "10.10.0"
|
||||
},
|
||||
"bin": {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@osm-asset/road-compiler",
|
||||
"version": "0.1.0",
|
||||
"version": "0.3.0",
|
||||
"private": false,
|
||||
"type": "commonjs",
|
||||
"main": "src/index.js",
|
||||
@@ -8,11 +8,12 @@
|
||||
"road-compiler": "bin/road-compiler.js"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "node test/index.js",
|
||||
"test:road-parity": "node test/road-parity.js",
|
||||
"road:workbench": "node bin/road-workbench.js"
|
||||
"test": "node test/index.js && node test/fixtures.js",
|
||||
"road:workbench": "node bin/road-workbench.js",
|
||||
"road:export": "node bin/road-compiler.js"
|
||||
},
|
||||
"dependencies": {
|
||||
"fflate": "0.8.3",
|
||||
"ol": "10.10.0"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
const fs = require("fs");
|
||||
const path = require("path");
|
||||
const { compileRoadModel, compileGeometry, loadOverrides, validateOverrides, writeJsonAtomic } = require("./native-road");
|
||||
const { LAYER_REGISTRY, manifestForArea, validatePublishedLayers } = require("./layer-manifest");
|
||||
const { loadOrGenerate, runtime } = require("../native-traffic-signals");
|
||||
|
||||
function compileInput(input) {
|
||||
@@ -53,7 +54,7 @@ function compileInput(input) {
|
||||
movements: compiled.movements,
|
||||
trafficSignals: { assemblies: "traffic-signal-assemblies.json", runtime: "traffic-signals.json", count: signalRuntime.signals.length },
|
||||
diagnostics: compiled.diagnostics,
|
||||
layers: { roadSurface: "layers/road_surface.geojson", edgeLines: "layers/edge_lines.geojson", sidewalkSurface: "layers/sidewalk_surface.geojson", intersectionSurface: "layers/intersection_surface.geojson", laneCenterlines: "layers/lane_centerlines.geojson", laneSeparators: "layers/lane_separators.geojson", centerLines: "layers/center_lines.geojson", directionArrows: "layers/direction_arrows.geojson", turnArrows: "layers/turn_arrows.geojson", crosswalks: "layers/crosswalks.geojson", vehicleStopLines: "layers/vehicle_stop_lines.geojson", connectors: "layers/connectors.geojson" },
|
||||
layers: Object.fromEntries(LAYER_REGISTRY.map((layer) => [layer.key, `layers/${layer.source}.geojson`])),
|
||||
};
|
||||
const comparison = compareOsm2Streets(area, result.model, compiled);
|
||||
writeJsonAtomic(path.join(staging, "compiled.json"), result);
|
||||
@@ -61,18 +62,10 @@ function compileInput(input) {
|
||||
writeJsonAtomic(path.join(staging, "comparison.json"), comparison);
|
||||
writeJsonAtomic(path.join(staging, "traffic-signal-assemblies.json"), signalDocument.assemblies);
|
||||
writeJsonAtomic(path.join(staging, "traffic-signals.json"), signalRuntime);
|
||||
writeJsonAtomic(path.join(staging, "layers", "road_surface.geojson"), compiled.roadSurface);
|
||||
writeJsonAtomic(path.join(staging, "layers", "edge_lines.geojson"), compiled.edgeLines);
|
||||
writeJsonAtomic(path.join(staging, "layers", "sidewalk_surface.geojson"), compiled.sidewalkSurface);
|
||||
writeJsonAtomic(path.join(staging, "layers", "intersection_surface.geojson"), compiled.intersectionSurface);
|
||||
writeJsonAtomic(path.join(staging, "layers", "lane_centerlines.geojson"), compiled.laneCenterlines);
|
||||
writeJsonAtomic(path.join(staging, "layers", "lane_separators.geojson"), compiled.laneSeparators);
|
||||
writeJsonAtomic(path.join(staging, "layers", "center_lines.geojson"), compiled.centerLines);
|
||||
writeJsonAtomic(path.join(staging, "layers", "direction_arrows.geojson"), compiled.directionArrows);
|
||||
writeJsonAtomic(path.join(staging, "layers", "turn_arrows.geojson"), compiled.turnArrows);
|
||||
writeJsonAtomic(path.join(staging, "layers", "crosswalks.geojson"), compiled.crosswalks);
|
||||
writeJsonAtomic(path.join(staging, "layers", "vehicle_stop_lines.geojson"), compiled.vehicleStopLines);
|
||||
writeJsonAtomic(path.join(staging, "layers", "connectors.geojson"), compiled.connectors);
|
||||
for (const layer of LAYER_REGISTRY) writeJsonAtomic(path.join(staging, "layers", `${layer.source}.geojson`), compiled[layer.key]);
|
||||
const manifest = manifestForArea(area.id);
|
||||
validatePublishedLayers(staging, manifest);
|
||||
writeJsonAtomic(path.join(staging, "manifest.json"), manifest);
|
||||
fs.rmSync(area.outputs.nativeRoadDir, { recursive: true, force: true });
|
||||
fs.renameSync(staging, area.outputs.nativeRoadDir);
|
||||
return { area, result, comparison };
|
||||
|
||||
49
src/compile/layer-manifest.js
Normal file
@@ -0,0 +1,49 @@
|
||||
"use strict";
|
||||
|
||||
// The compiler's layer registry is the single source of truth for published
|
||||
// GeoJSON files and the Blender-facing manifest. Keep rendering details limited
|
||||
// to material slot names; the host owns the actual material definitions.
|
||||
const LAYER_REGISTRY = Object.freeze([
|
||||
{ key: "roadSurface", source: "road_surface", role: "surface", materialLayer: "road_surface" },
|
||||
{ key: "edgeLines", source: "edge_lines", role: "marking", materialLayer: "lane_separators" },
|
||||
{ key: "intersectionSurface", source: "intersection_surface", role: "surface", materialLayer: "intersection_surface" },
|
||||
{ key: "sidewalkSurface", source: "sidewalk_surface", role: "surface", materialLayer: "sidewalks" },
|
||||
{ key: "laneSeparators", source: "lane_separators", role: "marking", materialLayer: "lane_separators", splitBy: { prop: "color", cases: [{ match: "yellow", material: "native_lane_separator_yellow" }, { default: true, material: "lane_separators" }] } },
|
||||
{ key: "centerLines", source: "center_lines", role: "marking", materialLayer: "center_lines", splitBy: { prop: "color", cases: [{ match: "white", material: "native_center_line_white" }, { default: true, material: "center_lines" }] } },
|
||||
{ key: "directionArrows", source: "direction_arrows", role: "marking", materialLayer: "lane_arrows_webscale" },
|
||||
{ key: "turnArrows", source: "turn_arrows", role: "marking", materialLayer: "lane_arrows_webscale" },
|
||||
{ key: "crosswalks", source: "crosswalks", role: "marking", materialLayer: "crosswalks" },
|
||||
{ key: "vehicleStopLines", source: "vehicle_stop_lines", role: "marking", materialLayer: "vehicle_stop_lines" },
|
||||
{ key: "laneCenterlines", source: "lane_centerlines", role: "semantic" },
|
||||
{ key: "connectors", source: "connectors", role: "semantic" },
|
||||
]);
|
||||
|
||||
function manifestForArea(areaId) {
|
||||
return {
|
||||
contract: "native-road-package/v1.1",
|
||||
areaId,
|
||||
layers: LAYER_REGISTRY.map(({ source, role, materialLayer, splitBy }) => ({
|
||||
source,
|
||||
role,
|
||||
...(materialLayer ? { materialLayer } : {}),
|
||||
...(splitBy ? { splitBy } : {}),
|
||||
})),
|
||||
};
|
||||
}
|
||||
|
||||
function validatePublishedLayers(directory, manifest) {
|
||||
const declared = new Set();
|
||||
for (const layer of manifest.layers) {
|
||||
if (!layer || typeof layer.source !== "string" || declared.has(layer.source)) throw new Error("Manifest has duplicate or invalid source.");
|
||||
declared.add(layer.source);
|
||||
const file = require("path").join(directory, "layers", `${layer.source}.geojson`);
|
||||
if (!require("fs").existsSync(file)) throw new Error(`Manifest source is missing: ${layer.source}`);
|
||||
}
|
||||
const files = require("fs").existsSync(require("path").join(directory, "layers"))
|
||||
? require("fs").readdirSync(require("path").join(directory, "layers")).filter((name) => name.endsWith(".geojson")).map((name) => name.slice(0, -8))
|
||||
: [];
|
||||
const extras = files.filter((source) => !declared.has(source));
|
||||
if (extras.length) throw new Error(`Unmanifested GeoJSON source: ${extras.join(", ")}`);
|
||||
}
|
||||
|
||||
module.exports = { LAYER_REGISTRY, manifestForArea, validatePublishedLayers };
|
||||
@@ -4,7 +4,7 @@ const fs = require("fs");
|
||||
const path = require("path");
|
||||
const { laneCenterline } = require("../geometry/lane-geometry");
|
||||
|
||||
const ASSET_MANIFEST = path.resolve(__dirname, "..", "..", "..", "..", "assets", "lane-icons", "manifest.json");
|
||||
const ASSET_MANIFEST = path.resolve(__dirname, "..", "..", "assets", "lane-icons", "manifest.json");
|
||||
const LANE_WIDTH_METERS = 3.2;
|
||||
const PLACEMENT_DISTANCE_METERS = 9;
|
||||
const SPATIAL_MATCH_MAX_DISTANCE_METERS = 18;
|
||||
|
||||
56
src/export/native-road-package.js
Normal file
@@ -0,0 +1,56 @@
|
||||
"use strict";
|
||||
|
||||
const fs = require("fs");
|
||||
const path = require("path");
|
||||
const { zipSync } = require("fflate");
|
||||
const { LAYER_REGISTRY, validatePublishedLayers } = require("../compile/layer-manifest");
|
||||
|
||||
const ROOT_FILES = [
|
||||
"manifest.json",
|
||||
"compiled.json",
|
||||
"diagnostics.json",
|
||||
"comparison.json",
|
||||
"traffic-signal-assemblies.json",
|
||||
"traffic-signals.json",
|
||||
];
|
||||
|
||||
const GENERATOR = Object.freeze({ name: "road-compiler", version: "0.3.0" });
|
||||
|
||||
function packageEntries(directory) {
|
||||
const manifestPath = path.join(directory, "manifest.json");
|
||||
if (!fs.existsSync(manifestPath)) throw new Error(`Native road package manifest is missing: ${manifestPath}`);
|
||||
const manifest = JSON.parse(fs.readFileSync(manifestPath, "utf8"));
|
||||
if (manifest.contract !== "native-road-package/v1.1") throw new Error("Native road package requires native-road-package/v1.1.");
|
||||
if (!manifest.areaId || typeof manifest.areaId !== "string") throw new Error("Native road package manifest areaId is required.");
|
||||
validatePublishedLayers(directory, manifest);
|
||||
const files = [];
|
||||
for (const relative of ROOT_FILES) files.push(relative);
|
||||
for (const layer of LAYER_REGISTRY) files.push(`layers/${layer.source}.geojson`);
|
||||
for (const relative of files) {
|
||||
const file = path.join(directory, relative);
|
||||
if (!fs.existsSync(file) || !fs.statSync(file).isFile()) throw new Error(`Native road package file is missing: ${relative}`);
|
||||
}
|
||||
return { manifest, files: [...new Set(files)].sort() };
|
||||
}
|
||||
|
||||
function exportNativeRoadPackage(directory, destination = null) {
|
||||
const { manifest, files } = packageEntries(directory);
|
||||
const entries = Object.fromEntries(files.map((relative) => [relative, fs.readFileSync(path.join(directory, relative))]));
|
||||
// The model/movements remain needed by host preview generation, but absolute
|
||||
// compiler-workspace paths are not part of the exported package contract.
|
||||
const compiled = JSON.parse(entries["compiled.json"].toString("utf8"));
|
||||
delete compiled.source;
|
||||
entries["compiled.json"] = Buffer.from(`${JSON.stringify(compiled, null, 2)}\n`);
|
||||
entries["manifest.json"] = Buffer.from(`${JSON.stringify({ ...manifest, generator: GENERATOR }, null, 2)}\n`);
|
||||
// ZIP timestamps start at 1980; a fixed value keeps repeated exports byte-stable.
|
||||
const bytes = zipSync(entries, { level: 6, mtime: new Date("1980-01-01T00:00:00Z") });
|
||||
if (destination) {
|
||||
fs.mkdirSync(path.dirname(destination), { recursive: true });
|
||||
const temporary = `${destination}.tmp-${process.pid}`;
|
||||
fs.writeFileSync(temporary, bytes);
|
||||
fs.renameSync(temporary, destination);
|
||||
}
|
||||
return { bytes, manifest, files };
|
||||
}
|
||||
|
||||
module.exports = { ROOT_FILES, GENERATOR, packageEntries, exportNativeRoadPackage };
|
||||
@@ -9,6 +9,8 @@ module.exports = {
|
||||
trafficSignals: require("./traffic-signals"),
|
||||
nativeTrafficSignals: require("./native-traffic-signals"),
|
||||
nativeRoad: require("./compile/native-road"),
|
||||
layerManifest: require("./compile/layer-manifest"),
|
||||
nativeRoadPackage: require("./export/native-road-package"),
|
||||
compiler: require("./compile/compiler"),
|
||||
check: require("./check"),
|
||||
};
|
||||
|
||||
49
test/fixtures.js
Normal file
@@ -0,0 +1,49 @@
|
||||
"use strict";
|
||||
|
||||
const assert = require("assert/strict");
|
||||
const crypto = require("crypto");
|
||||
const { execFileSync } = require("child_process");
|
||||
const fs = require("fs");
|
||||
const path = require("path");
|
||||
const { unzipSync, strFromU8 } = require("fflate");
|
||||
const { compiler } = require("../src");
|
||||
const { exportNativeRoadPackage } = require("../src/export/native-road-package");
|
||||
|
||||
const root = path.resolve(__dirname, "..");
|
||||
for (const areaId of ["fengshu-er-road", "nantaizi-lake-innovation-valley"]) {
|
||||
const isFengshu = areaId === "fengshu-er-road";
|
||||
const outputRoot = path.join(root, "outputs", areaId);
|
||||
const input = {
|
||||
areaId,
|
||||
osmFile: path.join(root, "inputs", "osm", isFengshu ? "枫树二路.osm" : "南台子湖创新谷OSM.osm"),
|
||||
outDir: path.join(outputRoot, "native-road"),
|
||||
stagingDir: path.join(outputRoot, "_pipeline"),
|
||||
overridesFile: path.join(outputRoot, "native-road-overrides.json"),
|
||||
trafficSignalsFile: path.join(outputRoot, "native-traffic-signals.json"),
|
||||
comparisonDir: path.join(outputRoot, "osm2streets_web_out"),
|
||||
options: { edgeLines: false, junctionTemplates: { enabled: false, references: [] } },
|
||||
};
|
||||
assert.ok(fs.existsSync(path.join(root, "test", "baseline", `${areaId}.json`)));
|
||||
const { result } = compiler.compileInput(input);
|
||||
assert.equal(result.areaId, areaId);
|
||||
assert.ok(fs.existsSync(path.join(input.outDir, "compiled.json")));
|
||||
const first = exportNativeRoadPackage(input.outDir);
|
||||
const second = exportNativeRoadPackage(input.outDir);
|
||||
assert.equal(crypto.createHash("sha256").update(first.bytes).digest("hex"), crypto.createHash("sha256").update(second.bytes).digest("hex"));
|
||||
const entries = unzipSync(first.bytes);
|
||||
const manifest = JSON.parse(strFromU8(entries["manifest.json"]));
|
||||
assert.equal(manifest.areaId, areaId);
|
||||
assert.equal(manifest.contract, "native-road-package/v1.1");
|
||||
assert.deepEqual(manifest.generator, { name: "road-compiler", version: "0.3.0" });
|
||||
assert.equal("source" in JSON.parse(strFromU8(entries["compiled.json"])), false);
|
||||
assert.equal(Object.keys(entries).some((entry) => entry.includes("override") || entry.endsWith(".osm")), false);
|
||||
assert.equal(Object.keys(entries).length, 18);
|
||||
if (isFengshu) {
|
||||
const inputFile = path.join(outputRoot, "road-compiler-input.json");
|
||||
const archive = path.join(outputRoot, "export.zip");
|
||||
fs.writeFileSync(inputFile, `${JSON.stringify(input)}\n`);
|
||||
execFileSync(process.execPath, [path.join(root, "bin", "road-compiler.js"), "--input", inputFile, "--export-zip", archive]);
|
||||
assert.ok(fs.existsSync(archive));
|
||||
}
|
||||
}
|
||||
console.log("road compiler fixture tests passed");
|
||||
@@ -11,6 +11,12 @@ assert.equal(typeof compiler.turnLaneArrows.buildCustomTurnLaneArrows, "function
|
||||
assert.equal(typeof compiler.complexJunction.buildComplexJunctionGeometry, "function");
|
||||
assert.equal(typeof compiler.nativeRoad.compileRoadModel, "function");
|
||||
assert.equal(typeof compiler.check.checkOutput, "function");
|
||||
assert.equal(typeof compiler.layerManifest.manifestForArea, "function");
|
||||
const manifest = compiler.layerManifest.manifestForArea("fixture");
|
||||
assert.equal(manifest.contract, "native-road-package/v1.1");
|
||||
assert.equal(manifest.layers.length, 12);
|
||||
assert.deepEqual(manifest.layers.filter((layer) => layer.role === "semantic").map((layer) => layer.source), ["lane_centerlines", "connectors"]);
|
||||
assert.equal(manifest.layers.find((layer) => layer.source === "center_lines").splitBy.cases[0].match, "white");
|
||||
const fixture = path.join(__dirname, "fixtures", "fengshu-er-road.osm");
|
||||
assert.ok(fs.existsSync(fixture));
|
||||
assert.throws(() => compiler.compiler.validateInput({ id: "area" }), /RoadCompilerInput/);
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
<!doctype html>
|
||||
<html lang="zh-CN"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1"><title>道路编译工作台</title><link rel="stylesheet" href="/vendor/ol/ol.css"><link rel="stylesheet" href="/app.css"></head>
|
||||
<body><header><strong>道路编译工作台</strong><span id="area"></span><span id="status"></span><span id="dirty-state" aria-live="polite"></span><label style="display:inline;margin:0 0 0 auto;white-space:nowrap"><input id="scene-preview" type="checkbox"> 场景效果</label><button id="save">保存修改</button><button id="compile">保存并重新生成</button></header>
|
||||
<body><header><strong>道路编译工作台</strong><span id="area"></span><span id="status"></span><span id="dirty-state" aria-live="polite"></span><label style="display:inline;margin:0 0 0 auto;white-space:nowrap"><input id="scene-preview" type="checkbox"> 场景效果</label><a id="export-package" href="/api/export.zip" download>导出道路包</a><button id="save">保存修改</button><button id="compile">保存并重新生成</button></header>
|
||||
<main><aside class="issues"><h1>图层</h1><label><input data-layer="osm" type="checkbox" checked> OSM 道路中心线</label><label><input data-layer="native" type="checkbox" checked> 自研道路与路口面</label><label><input data-layer="sidewalks" type="checkbox" checked> 路缘与步行带</label><label><input data-layer="lanes" type="checkbox" checked> 车道与转向路径</label><label><input data-layer="gaodeReference" type="checkbox" checked> 高德规整路口参考</label><label><input data-layer="reference" type="checkbox"> osm2streets 参考面</label><hr><h1>当前编译概览</h1><dl id="summary"></dl><hr><h1>待检查问题</h1><div id="diagnostic-filters" class="segmented"><button data-diagnostic-filter="all" type="button">全部</button><button data-diagnostic-filter="candidates" type="button">可连接</button><button data-diagnostic-filter="other" type="button">其他</button></div><ul id="diagnostics"></ul></aside><section id="map" class="map"></section><aside class="inspector"><h1>当前道路设置</h1><p id="hint">点击道路、车道、转向路径或路口面以查看详情。</p><section id="selected-junction" hidden><h2>当前路口</h2><output id="junction-detail"></output></section><form id="road-form" hidden><label>道路</label><output id="road-name"></output><output id="movement-summary"></output><output id="lane-convention"></output><section id="selected-movement" hidden><h2>当前行驶动作</h2><output id="movement-detail"></output></section><div id="direction-switch"></div><label>本方向道路宽度(米)<input id="width" type="number" min="1" step="0.01"></label><label>本方向车道数<input id="lanes" type="number" min="1" step="1"></label><label><input id="left" type="checkbox"> 左侧有路缘与步行带</label><label><input id="right" type="checkbox"> 右侧有路缘与步行带</label><button type="submit">暂存本道路修改</button></form><form id="center-line-form" hidden><h2 id="marking-style-heading">道路中心线样式</h2><output id="center-line-segment"></output><label>样式<select id="center-line-style"><option value="yellow-dashed">黄色虚线(默认)</option><option value="white-dashed">白色虚线</option><option value="yellow-solid">黄色实线</option><option value="white-solid">白色实线</option></select></label><button type="submit">暂存标线样式</button></form><hr><h2>路口连接</h2><div id="connections">请选择一条道路。</div><button id="add-connection" type="button" hidden>手工新增驶出连接</button><details><summary>技术详情与来源</summary><pre id="evidence">无</pre></details></aside></main><script type="importmap">{"imports":{"rbush":"/vendor/rbush/index.js","quickselect":"/vendor/quickselect/index.js"}}</script><script type="module" src="/app.js"></script></body></html>
|
||||
|
||||
@@ -7,6 +7,7 @@ const path = require("path");
|
||||
const { loadOverrides, validateOverrides, writeJsonAtomic } = require("../src/compile/native-road");
|
||||
const { generate, validateDocument, runtime } = require("../src/native-traffic-signals");
|
||||
const { convertGeoJson } = require("../src/reference/gaode");
|
||||
const { exportNativeRoadPackage } = require("../src/export/native-road-package");
|
||||
|
||||
function startWorkbench({ area, configPath, repoRoot, compileFresh, readAreaConfig, junctionReference = null, debug = false, port = 8787 }) {
|
||||
if (typeof junctionReference === "string") junctionReference = readJunctionReference(junctionReference);
|
||||
@@ -31,6 +32,16 @@ function handle(request, response, area, context, junctionReference, debug = fal
|
||||
if (request.method === "GET" && url.pathname === "/app.css") return sendFile(response, path.join(__dirname, "client", "app.css"), "text/css; charset=utf-8");
|
||||
if (request.method === "GET" && url.pathname.startsWith("/vendor/")) return sendVendorFile(response, url.pathname, context.repoRoot);
|
||||
if (request.method === "GET" && url.pathname === "/api/state") return sendJson(response, 200, state(area, junctionReference, debug));
|
||||
if (request.method === "GET" && url.pathname === "/api/export.zip") return Promise.resolve().then(() => {
|
||||
const exported = exportNativeRoadPackage(area.outputs.nativeRoadDir);
|
||||
response.writeHead(200, {
|
||||
"Content-Type": "application/zip",
|
||||
"Content-Disposition": `attachment; filename="${area.id}.native-road.zip"`,
|
||||
"Content-Length": exported.bytes.length,
|
||||
"Cache-Control": "no-store",
|
||||
});
|
||||
response.end(Buffer.from(exported.bytes));
|
||||
}).catch((error) => sendJson(response, 400, { ok: false, error: error.message }));
|
||||
if (request.method === "POST" && url.pathname === "/api/traffic-signals") return readBody(request).then((body) => {
|
||||
const document = validateDocument(body, fs.readFileSync(area.input, "utf8"));
|
||||
writeJsonAtomic(area.outputs.nativeTrafficSignals, document);
|
||||
|
||||