mirror of
https://github.com/firestar5683/StarPilot.git
synced 2026-12-02 02:13:41 +08:00
Add Russian offline speed map regions
This commit is contained in:
@@ -65,8 +65,9 @@ func BundledManagedRegions() ([]ManagedRegion, error) {
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
result := make([]ManagedRegion, 0, 242)
|
||||
for _, group := range []string{"nation", "us_state", "ca_province"} {
|
||||
result := make([]ManagedRegion, 0, 252)
|
||||
// Russian district rectangles follow Geofabrik extract envelopes, split at ±180°.
|
||||
for _, group := range []string{"nation", "us_state", "ca_province", "ru_district"} {
|
||||
for key, data := range menu[group] {
|
||||
if key == "" || strings.Contains(key, ".") || data.FullName == "" {
|
||||
return nil, errors.New("invalid bundled region")
|
||||
|
||||
@@ -11,7 +11,7 @@ func TestBundledManagedRegionCoverage(t *testing.T) {
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if len(regions) != 242 {
|
||||
if len(regions) != 252 {
|
||||
t.Fatalf("bundled catalog changed: %d", len(regions))
|
||||
}
|
||||
available := 0
|
||||
@@ -23,7 +23,7 @@ func TestBundledManagedRegionCoverage(t *testing.T) {
|
||||
}
|
||||
}
|
||||
}
|
||||
if available != 238 {
|
||||
if available != 248 {
|
||||
t.Fatalf("review supported-region count changed: %d", available)
|
||||
}
|
||||
for token, groups := range map[string]int{"us_state.CA": 36, "us_state.TX": 56, "us_state.IL": 12, "nation.CA": 765, "nation.JP": 72, "nation.US": 390} {
|
||||
@@ -39,6 +39,23 @@ func TestBundledManagedRegionCoverage(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestRussianDistrictCoverage(t *testing.T) {
|
||||
for token, want := range map[string]struct {
|
||||
bounds [4]float64
|
||||
groups int
|
||||
}{
|
||||
"central": {[4]float64{48, 30, 60, 48}, 54},
|
||||
"moscow": {[4]float64{54, 36, 58, 40}, 4},
|
||||
"far-east": {[4]float64{36, 104, 84, 180}, 912},
|
||||
"far-east-dateline": {[4]float64{62, -180, 74, -168}, 36},
|
||||
} {
|
||||
region, err := ResolveManagedRegion("ru_district." + token)
|
||||
if err != nil || region.Bounds != want.bounds || region.Groups != want.groups {
|
||||
t.Fatalf("%s: %+v %v", token, region, err)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Province coverage comes from the pinned Geofabrik extract envelopes. Every
|
||||
// envelope must survive outward grid alignment without losing any edge.
|
||||
func TestCanadianProvinceCoverage(t *testing.T) {
|
||||
|
||||
@@ -2183,5 +2183,97 @@
|
||||
"max_lat": 70.16293
|
||||
}
|
||||
}
|
||||
},
|
||||
"ru_district": {
|
||||
"central": {
|
||||
"full_name": "Russia - Central Federal District",
|
||||
"bounding_box": {
|
||||
"min_lon": 30.6998,
|
||||
"min_lat": 49.5045,
|
||||
"max_lon": 47.6702,
|
||||
"max_lat": 59.6533
|
||||
}
|
||||
},
|
||||
"far-east": {
|
||||
"full_name": "Russia - Far Eastern Federal District (main area)",
|
||||
"bounding_box": {
|
||||
"min_lon": 105.4219,
|
||||
"min_lat": 37.3466,
|
||||
"max_lon": 180,
|
||||
"max_lat": 82.0002
|
||||
}
|
||||
},
|
||||
"far-east-dateline": {
|
||||
"full_name": "Russia - Far Eastern Federal District (across the date line)",
|
||||
"bounding_box": {
|
||||
"min_lon": -180,
|
||||
"min_lat": 62.2613,
|
||||
"max_lon": -168.6841,
|
||||
"max_lat": 72.2393
|
||||
}
|
||||
},
|
||||
"moscow": {
|
||||
"full_name": "Russia - Moscow area",
|
||||
"bounding_box": {
|
||||
"min_lon": 36,
|
||||
"min_lat": 54,
|
||||
"max_lon": 40,
|
||||
"max_lat": 58
|
||||
}
|
||||
},
|
||||
"north-caucasus": {
|
||||
"full_name": "Russia - North Caucasus Federal District",
|
||||
"bounding_box": {
|
||||
"min_lon": 40.6726,
|
||||
"min_lat": 41.1355,
|
||||
"max_lon": 48.8645,
|
||||
"max_lat": 46.2391
|
||||
}
|
||||
},
|
||||
"northwestern": {
|
||||
"full_name": "Russia - Northwestern Federal District",
|
||||
"bounding_box": {
|
||||
"min_lon": 19.4084,
|
||||
"min_lat": 54.3128,
|
||||
"max_lon": 72.6248,
|
||||
"max_lat": 82.5456
|
||||
}
|
||||
},
|
||||
"siberian": {
|
||||
"full_name": "Russia - Siberian Federal District",
|
||||
"bounding_box": {
|
||||
"min_lon": 70.2748,
|
||||
"min_lat": 49.021,
|
||||
"max_lon": 147.7133,
|
||||
"max_lat": 81.8875
|
||||
}
|
||||
},
|
||||
"southern": {
|
||||
"full_name": "Russia - Southern Federal District",
|
||||
"bounding_box": {
|
||||
"min_lon": 36.5232,
|
||||
"min_lat": 43.1896,
|
||||
"max_lon": 49.9367,
|
||||
"max_lat": 51.2554
|
||||
}
|
||||
},
|
||||
"ural": {
|
||||
"full_name": "Russia - Ural Federal District",
|
||||
"bounding_box": {
|
||||
"min_lon": 57.0426,
|
||||
"min_lat": 51.8264,
|
||||
"max_lon": 86.0952,
|
||||
"max_lat": 75.011
|
||||
}
|
||||
},
|
||||
"volga": {
|
||||
"full_name": "Russia - Volga Federal District",
|
||||
"bounding_box": {
|
||||
"min_lon": 41.7211,
|
||||
"min_lat": 49.751,
|
||||
"max_lon": 61.7337,
|
||||
"max_lat": 61.7197
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -190,3 +190,12 @@ assert.equal(findRegions('Canada').some((r) => r.token === 'ca_province.ON'), tr
|
||||
assert.equal(MapOperationsPanel.computed.canadianRegions.call({ regions: findRegions('Canada') }).length, 1)
|
||||
assert.equal(MapOperationsPanel.computed.otherRegions.call({ regions: findRegions('Canada') })[0].token, 'nation.CA')
|
||||
assert.equal(MapOperationsPanel.computed.canadianRegions.call({ regions: largeCatalog.regions }).length, 0)
|
||||
|
||||
const moscow = { token: 'ru_district.moscow', name: 'Russia - Moscow area', bounds: [54, 36, 58, 40], groups: 4, available: true }
|
||||
const central = { token: 'ru_district.central', name: 'Russia - Central Federal District', bounds: [48, 30, 60, 48], groups: 54, available: true }
|
||||
const russianCatalog = { ...largeCatalog, regions: [...largeCatalog.regions, moscow, central] }
|
||||
assert.equal(validCatalog(russianCatalog), true)
|
||||
const russianSearch = search => MapOperationsPanel.computed.regions.call({ search, catalog: russianCatalog })
|
||||
assert.deepEqual(russianSearch('Moscow'), [moscow])
|
||||
assert.deepEqual(russianSearch('Central'), [central])
|
||||
assert.deepEqual(MapOperationsPanel.computed.russianRegions.call({ regions: russianSearch('Russia') }), [moscow, central])
|
||||
|
||||
@@ -5,7 +5,7 @@ import { requestJson } from "./startup.js"
|
||||
// One parked map operation belongs to the local owner, not to this browser tab.
|
||||
const STATES = new Set(["idle", "transferring", "validating", "selecting", "completed", "canceled", "failed", "interrupted", "unavailable"])
|
||||
const GENERATION = /^(?:|[0-9a-f]{64})$/
|
||||
const TOKEN = /^(?:nation|us_state|ca_province)\.[A-Za-z0-9_-]+$/
|
||||
const TOKEN = /^(?:nation|us_state|ca_province|ru_district)\.[A-Za-z0-9_-]+$/
|
||||
const ERROR_LABELS = {
|
||||
canceled: "Canceled", interrupted: "Interrupted", selection_changed: "The saved selection changed",
|
||||
not_parked: "Parked availability was lost", package_unavailable: "The map package is unavailable",
|
||||
@@ -293,7 +293,8 @@ export const MapOperationsPanel = {
|
||||
`${item.token.startsWith("ca_province.") ? "Canada " : ""}${item.name} ${item.token}`.toLocaleLowerCase().includes(query))
|
||||
},
|
||||
canadianRegions() { return this.regions.filter((item) => item.token.startsWith("ca_province.")) },
|
||||
otherRegions() { return this.regions.filter((item) => !item.token.startsWith("ca_province.")) },
|
||||
russianRegions() { return this.regions.filter((item) => item.token.startsWith("ru_district.")) },
|
||||
otherRegions() { return this.regions.filter((item) => !item.token.startsWith("ca_province.") && !item.token.startsWith("ru_district.")) },
|
||||
running() { return ["transferring", "validating", "selecting"].includes(this.operation?.state) },
|
||||
},
|
||||
methods: {
|
||||
@@ -337,13 +338,14 @@ export const MapOperationsPanel = {
|
||||
<button v-if="running" type="button" class="gx-btn gx-btn--tonal" @click="client.cancel()">Cancel operation</button>
|
||||
</template>
|
||||
<div class="gx-map-manager__picker"><label for="map-region-search">Search regions</label>
|
||||
<input id="map-region-search" class="gx-field" type="search" v-model="search" placeholder="Country, province, territory or US state"></div>
|
||||
<input id="map-region-search" class="gx-field" type="search" v-model="search" placeholder="Country, state, province or district"></div>
|
||||
<p v-if="!catalog && setup?.packageReady && !error" role="status">Loading map catalog…</p>
|
||||
<template v-if="catalog"><p class="gx-note">{{ regions.length }} regions shown · Up to {{ formatBytes(catalog.maxTransferBytes) }} transfer · {{ formatBytes(catalog.maxNewDiskBytes) }} new storage.</p>
|
||||
<div class="gx-map-manager__regions">
|
||||
<div v-for="region in otherRegions" :key="region.token" class="gx-map-manager__region">
|
||||
<div><strong>{{ region.token === 'nation.CA' ? 'Canada — All Canada' : region.name }}</strong><small>{{ region.token }} · {{ region.groups }} groups</small>
|
||||
<small v-if="!region.available">Unavailable: {{ region.unavailable.replaceAll('_', ' ') }}</small></div>
|
||||
<small v-if="region.token === 'nation.RU' && russianRegions.length">Choose a Russian district or the Moscow area below.</small>
|
||||
<small v-else-if="!region.available">Unavailable: {{ region.unavailable.replaceAll('_', ' ') }}</small></div>
|
||||
<button type="button" class="gx-btn gx-btn--tonal" :disabled="running || !region.available || !operation" @click="reviewRegion(region)">Review…</button>
|
||||
</div>
|
||||
<details v-if="canadianRegions.length" :open="search.trim() ? true : undefined">
|
||||
@@ -354,6 +356,14 @@ export const MapOperationsPanel = {
|
||||
<button type="button" class="gx-btn gx-btn--tonal" :disabled="running || !region.available || !operation" @click="reviewRegion(region)">Review…</button>
|
||||
</div>
|
||||
</details>
|
||||
<details v-if="russianRegions.length" :open="search.trim() ? true : undefined">
|
||||
<summary>Russia: Districts and Moscow</summary>
|
||||
<div v-for="region in russianRegions" :key="region.token" class="gx-map-manager__region">
|
||||
<div><strong>{{ region.name }}</strong><small>{{ region.groups }} groups</small>
|
||||
<small v-if="!region.available">Unavailable: {{ region.unavailable.replaceAll('_', ' ') }}</small></div>
|
||||
<button type="button" class="gx-btn gx-btn--tonal" :disabled="running || !region.available || !operation" @click="reviewRegion(region)">Review…</button>
|
||||
</div>
|
||||
</details>
|
||||
</div></template>
|
||||
</template>
|
||||
</div>
|
||||
|
||||
@@ -39,7 +39,7 @@ MAX_TRANSFER_BYTES = 8 * 1024**3
|
||||
MAX_NEW_DISK_BYTES = 16 * 1024**3
|
||||
OPERATION_DEADLINE_S = 30 * 60
|
||||
GENERATION = re.compile(r'[0-9a-f]{64}\Z')
|
||||
TOKEN = re.compile(r'(?:nation|us_state|ca_province)\.[A-Za-z0-9_-]{1,64}\Z')
|
||||
TOKEN = re.compile(r'(?:nation|us_state|ca_province|ru_district)\.[A-Za-z0-9_-]{1,64}\Z')
|
||||
ACTIVE = frozenset(('transferring', 'validating', 'selecting'))
|
||||
STATES = frozenset(('idle', 'transferring', 'validating', 'selecting', 'completed',
|
||||
'canceled', 'failed', 'interrupted', 'unavailable'))
|
||||
@@ -283,7 +283,7 @@ def _catalog() -> list[dict]:
|
||||
if len(completed.stdout) > MAX_CATALOG or len(completed.stderr) > MAX_STATUS:
|
||||
raise ValueError('catalog output exceeds bound')
|
||||
rows = json.loads(completed.stdout, object_pairs_hook=_unique_object)
|
||||
if type(rows) is not list or len(rows) not in (229, 242):
|
||||
if type(rows) is not list or len(rows) not in (229, 242, 252):
|
||||
raise ValueError('catalog shape invalid')
|
||||
seen = set()
|
||||
for row in rows:
|
||||
|
||||
@@ -1 +1 @@
|
||||
{"binarySha256":"25b24f44ca2e109477ed863a4d22493dcf6ac38b8921c572487ff84c9f5900eb","goVersion":"go1.25.1","schemaVersion":1,"sourceDigest":"7ddd6ad351392c7522dd12f6617914a862e71010eccc355ef09c91cbd217be3d","sourceRevision":"afcd2179fca9a17a3ae87b3aa47f1a62e9dea840","target":"linux-arm64-static","upstreamRevision":"7201c6b4b4ec1b0b9ea21daa8c05b80fdd7e01ee"}
|
||||
{"binarySha256":"72e46f007b4dd5a813148aa3ea3fc7170db2d01004db5884b0895fafd00508e0","goVersion":"go1.25.1","schemaVersion":1,"sourceDigest":"736914d0326a3785673227d36b8e189e1ee7d0cbb87a9d8b725607810d8cde9f","sourceRevision":"291fc1d62f84fae5875fd4fb66185657e1f1f113","target":"linux-arm64-static","upstreamRevision":"7201c6b4b4ec1b0b9ea21daa8c05b80fdd7e01ee"}
|
||||
|
||||
Binary file not shown.
@@ -264,6 +264,15 @@ class TestMapSnapshotOperationOwner(unittest.TestCase):
|
||||
with patch.object(ops.subprocess, 'run', return_value=completed):
|
||||
self.assertEqual([row['token'] for row in ops._catalog()[229:]], [f'ca_province.{code}' for code in codes])
|
||||
|
||||
def test_catalog_accepts_russian_regions_from_provider(self):
|
||||
rows = [{**REGION, 'token': f'nation.region{i}'} for i in range(249)]
|
||||
tokens = ['ru_district.central', 'ru_district.moscow', 'ru_district.far-east-dateline']
|
||||
rows.extend({**REGION, 'token': token} for token in tokens)
|
||||
completed = subprocess.CompletedProcess([], 0, json.dumps(rows).encode(), b'')
|
||||
with patch.object(ops.subprocess, 'run', return_value=completed):
|
||||
self.assertEqual([row['token'] for row in ops._catalog()[-3:]], tokens)
|
||||
self.assertIsNone(ops.TOKEN.fullmatch('ru_district.moscow.extra'))
|
||||
|
||||
def test_catalog_rejects_incomplete_and_duplicate_regions(self):
|
||||
for count in (0, 1, 228, 230, 241, 243):
|
||||
with self.subTest(count=count):
|
||||
|
||||
+1
-1
@@ -1 +1 @@
|
||||
{"protected_inventory_sha256": "6bf8757a417f15eecccc73d5b571f3c773ffb9ba7b04fa9025a7f3eb28331b1d", "schema_version": 1}
|
||||
{"protected_inventory_sha256": "26b6ba13d244384ea4cc83374b8ea16c870e6e7d0ff93745fa67b0afdfd3e731", "schema_version": 1}
|
||||
|
||||
Reference in New Issue
Block a user