Skip to content

Commit

Permalink
check for entities without metainformation and filter them out
Browse files Browse the repository at this point in the history
  • Loading branch information
danielfeismann committed May 14, 2024
1 parent 852e20b commit b76d1b4
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 10 deletions.
7 changes: 5 additions & 2 deletions src/main/scala/edu/ie3/osmogrid/model/OsmoGridModel.scala
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

package edu.ie3.osmogrid.model

import com.typesafe.scalalogging.LazyLogging
import edu.ie3.osmogrid.model.SourceFilter.{Filter, LvFilter}
import edu.ie3.util.osm.model.OsmContainer.ParOsmContainer
import edu.ie3.util.osm.model.OsmEntity.Relation.RelationMemberType
Expand All @@ -23,7 +24,7 @@ sealed trait OsmoGridModel {
def +(additional: OsmoGridModel): Option[OsmoGridModel]
}

object OsmoGridModel {
object OsmoGridModel extends LazyLogging {

def filterForSubstations(
entities: ParSeq[EnhancedOsmEntity]
Expand Down Expand Up @@ -126,7 +127,9 @@ object OsmoGridModel {
entities.filter {
case entity: E if entity.metaInformation.isDefined =>
entity.metaInformation.exists(_.version.contains(maxVersion))
case _ => true
case entity: E if !entity.metaInformation.isDefined =>
logger.info(s"Warning: ${entity.id} does not contain any meta information to identify the version id of the OsmEntity, so it was filtered out.")
false
}
}
.toSeq
Expand Down
24 changes: 16 additions & 8 deletions src/test/scala/edu/ie3/osmogrid/model/OsmTestData.scala
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ trait OsmTestData {
nodes.building1Node1.id
),
Map("building" -> "yes"),
None
Some(OsmEntity.MetaInformation(Some(0), None, None, None, None, None))
)

val building2: ClosedWay =
Expand All @@ -166,7 +166,7 @@ trait OsmTestData {
nodes.building2Node1.id
),
Map("building" -> "yes"),
None
Some(OsmEntity.MetaInformation(Some(0), None, None, None, None, None))
)

val building3: ClosedWay =
Expand All @@ -180,15 +180,15 @@ trait OsmTestData {
nodes.building3Node1.id
),
Map("building" -> "yes"),
None
Some(OsmEntity.MetaInformation(Some(0), None, None, None, None, None))
)

val highway1: OpenWay =
OpenWay(
111L,
Seq(nodes.highway1Node1.id, nodes.highway1Node2.id),
Map("highway" -> "motorway"),
None
Some(OsmEntity.MetaInformation(Some(0), None, None, None, None, None))
)

val highway2: OpenWay =
Expand Down Expand Up @@ -218,6 +218,14 @@ trait OsmTestData {
Some(OsmEntity.MetaInformation(Some(0), None, None, None, None, None))
)

val highway4: OpenWay =
OpenWay(
114L,
Seq(nodes.highway1Node1.id, nodes.highway1Node2.id),
Map("highway" -> "motorway"),
None
)

val landuse1: ClosedWay = ClosedWay(
121L,
Seq(
Expand All @@ -228,7 +236,7 @@ trait OsmTestData {
nodes.landuse1Node1.id
),
Map("landuse" -> "education"),
None
Some(OsmEntity.MetaInformation(Some(0), None, None, None, None, None))
)

val landuse2: ClosedWay = ClosedWay(
Expand All @@ -241,11 +249,11 @@ trait OsmTestData {
nodes.landuse2Node1.id
),
Map.empty[String, String],
None
Some(OsmEntity.MetaInformation(Some(0), None, None, None, None, None))
)

val landuse3: ClosedWay = ClosedWay(
122L,
123L,
Seq(
nodes.landuse3Node1.id,
nodes.landuse3Node2.id,
Expand All @@ -254,7 +262,7 @@ trait OsmTestData {
nodes.landuse3Node1.id
),
Map("landuse" -> "residential"),
None
Some(OsmEntity.MetaInformation(Some(0), None, None, None, None, None))
)

val boundaryWay1: OpenWay = OpenWay(
Expand Down

0 comments on commit b76d1b4

Please sign in to comment.