Area centro 13.35,38.11,0 13.37,38.11,0 13.37,38.13,0 13.35,38.11,0 XML; protected function setUp(): void { parent::setUp(); Storage::fake('local'); } public function test_un_poligono_con_namespace_ogc_viene_riconosciuto(): void { $geojson = (new PiantineArea())->kmlInGeoJson(self::KML_POLIGONO); $this->assertSame('FeatureCollection', $geojson['type']); $this->assertCount(1, $geojson['features']); $feature = $geojson['features'][0]; $this->assertSame('Area centro', $feature['properties']['name']); $this->assertSame('Polygon', $feature['geometry']['type']); $this->assertSame([13.35, 38.11], $feature['geometry']['coordinates'][0][0]); $this->assertCount(4, $feature['geometry']['coordinates'][0]); } public function test_una_linestring_senza_namespace_viene_riconosciuta(): void { $kml = <<<'XML' Perimetro 13.1,38.1 13.2,38.2 13.3,38.1 XML; $geojson = (new PiantineArea())->kmlInGeoJson($kml); $this->assertCount(1, $geojson['features']); $this->assertSame('LineString', $geojson['features'][0]['geometry']['type']); $this->assertCount(3, $geojson['features'][0]['geometry']['coordinates']); } public function test_un_kml_senza_geometrie_viene_rifiutato(): void { $this->expectException(RuntimeException::class); (new PiantineArea())->salvaKml('', 'vuoto.kml'); } public function test_un_file_non_xml_viene_rifiutato(): void { $this->expectException(RuntimeException::class); (new PiantineArea())->salvaKml('questo non รจ xml', 'rotto.kml'); } public function test_salva_kml_scrive_area_e_configurazione(): void { $area = new PiantineArea(); $quante = $area->salvaKml(self::KML_POLIGONO, 'citta.kml'); $this->assertSame(1, $quante); Storage::disk('local')->assertExists('piantine/area.kml'); Storage::disk('local')->assertExists('piantine/area.geojson'); $this->assertSame('citta.kml', $area->config()['kml_nome']); $this->assertSame('Polygon', $area->area()['features'][0]['geometry']['type']); } }