mirror of
https://github.com/dcs-retribution/dcs-retribution.git
synced 2025-11-10 15:41:24 +00:00
Make generate_landmap importable.
This file may not be needed long term, but for now I want to import to_multipoly for some other work.
This commit is contained in:
parent
db4b43f495
commit
fa4bf3d516
@ -32,40 +32,53 @@ def _geometry_collection_to_multipoly(obj: GeometryCollection) -> MultiPolygon:
|
||||
raise RuntimeError(f"Not sure how to convert collection to multipoly: {obj.wkt}")
|
||||
|
||||
|
||||
for terrain in ["cau", "nev", "syria", "channel", "normandy", "gulf", "marianaislands"]:
|
||||
print("Terrain " + terrain)
|
||||
m = Mission()
|
||||
m.load_file("./{}_terrain.miz".format(terrain))
|
||||
def main() -> None:
|
||||
for terrain in [
|
||||
"cau",
|
||||
"nev",
|
||||
"syria",
|
||||
"channel",
|
||||
"normandy",
|
||||
"gulf",
|
||||
"marianaislands",
|
||||
]:
|
||||
print("Terrain " + terrain)
|
||||
m = Mission()
|
||||
m.load_file("./{}_terrain.miz".format(terrain))
|
||||
|
||||
inclusion_zones = []
|
||||
exclusion_zones = []
|
||||
seas_zones = []
|
||||
for plane_group in m.country("USA").plane_group:
|
||||
zone = [(x.position.x, x.position.y) for x in plane_group.points]
|
||||
inclusion_zones = []
|
||||
exclusion_zones = []
|
||||
seas_zones = []
|
||||
for plane_group in m.country("USA").plane_group:
|
||||
zone = [(x.position.x, x.position.y) for x in plane_group.points]
|
||||
|
||||
if terrain == "cau" and inclusion_zones:
|
||||
# legacy
|
||||
exclusion_zones.append(Polygon(zone))
|
||||
else:
|
||||
poly = Polygon(zone)
|
||||
if not poly.is_valid:
|
||||
raise RuntimeError(f"{plane_group} is invalid")
|
||||
if plane_group.units[0].type == "F-15C":
|
||||
exclusion_zones.append(poly)
|
||||
if terrain == "cau" and inclusion_zones:
|
||||
# legacy
|
||||
exclusion_zones.append(Polygon(zone))
|
||||
else:
|
||||
inclusion_zones.append(poly)
|
||||
poly = Polygon(zone)
|
||||
if not poly.is_valid:
|
||||
raise RuntimeError(f"{plane_group} is invalid")
|
||||
if plane_group.units[0].type == "F-15C":
|
||||
exclusion_zones.append(poly)
|
||||
else:
|
||||
inclusion_zones.append(poly)
|
||||
|
||||
for ship_group in m.country("USA").ship_group:
|
||||
zone = [(x.position.x, x.position.y) for x in ship_group.points]
|
||||
seas_zones.append(Polygon(zone))
|
||||
for ship_group in m.country("USA").ship_group:
|
||||
zone = [(x.position.x, x.position.y) for x in ship_group.points]
|
||||
seas_zones.append(Polygon(zone))
|
||||
|
||||
with open("../{}landmap.p".format(terrain), "wb") as f:
|
||||
print(len(inclusion_zones), len(exclusion_zones), len(seas_zones))
|
||||
pickle.dump(
|
||||
Landmap(
|
||||
to_multipoly(unary_union(inclusion_zones)),
|
||||
to_multipoly(unary_union(exclusion_zones)),
|
||||
to_multipoly(unary_union(seas_zones)),
|
||||
),
|
||||
f,
|
||||
)
|
||||
with open("../{}landmap.p".format(terrain), "wb") as f:
|
||||
print(len(inclusion_zones), len(exclusion_zones), len(seas_zones))
|
||||
pickle.dump(
|
||||
Landmap(
|
||||
to_multipoly(unary_union(inclusion_zones)),
|
||||
to_multipoly(unary_union(exclusion_zones)),
|
||||
to_multipoly(unary_union(seas_zones)),
|
||||
),
|
||||
f,
|
||||
)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user