Skip to content

Commit

Permalink
Checkstyle corrections.
Browse files Browse the repository at this point in the history
  • Loading branch information
Szymon Rachański committed Jan 3, 2021
1 parent f138496 commit 735b45c
Show file tree
Hide file tree
Showing 4 changed files with 65 additions and 53 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -58,12 +58,6 @@ public BoundaryIntersectionCheck(final Configuration configuration)
super(configuration);
}

private static boolean isObjectOfBoundaryTypeWithBoundaryTag(final AtlasObject object)
{
return Validators.isOfType(object, RelationTypeTag.class, RelationTypeTag.BOUNDARY)
&& Validators.hasValuesFor(object, BoundaryTag.class);
}

private static boolean isRelationTypeBoundaryWithBoundaryTag(final AtlasObject object)
{
return Validators.isOfType(object, RelationTypeTag.class, RelationTypeTag.BOUNDARY)
Expand All @@ -73,7 +67,7 @@ private static boolean isRelationTypeBoundaryWithBoundaryTag(final AtlasObject o
@Override
public boolean validCheckForObject(final AtlasObject object)
{
return object instanceof Relation && isObjectOfBoundaryTypeWithBoundaryTag(object);
return object instanceof Relation && isRelationTypeBoundaryWithBoundaryTag(object);
}

@Override
Expand Down Expand Up @@ -110,8 +104,6 @@ private Optional<CheckFlag> processRelation(final AtlasObject object)
{
final CheckFlag checkFlag = new CheckFlag(this.getTaskIdentifier(object));
instructions.forEach(checkFlag::addInstruction);
//TODO remove
instructions.forEach(System.out::println);
checkFlag.addObjects(objectsToFlag);
return Optional.of(checkFlag);
}
Expand Down Expand Up @@ -220,7 +212,7 @@ private Map<String, Relation> getRelationMap(final AtlasObject object)
{
((MultiRelation) object).relations()
.stream()
.filter(BoundaryIntersectionCheck::isObjectOfBoundaryTypeWithBoundaryTag)
.filter(BoundaryIntersectionCheck::isRelationTypeBoundaryWithBoundaryTag)
.forEach(relation -> tagToRelation.put(relation.getTag(BOUNDARY).get(), relation));
}
tagToRelation.put(object.getTag(BOUNDARY).get(), (Relation) object);
Expand Down Expand Up @@ -294,8 +286,8 @@ private Coordinate[] getIntersectionPoints(final String wktFirst,
{
try
{
Geometry geometry1 = getGeometryForIntersection(wktFirst);
Geometry geometry2 = getGeometryForIntersection(wktSecond);
final Geometry geometry1 = this.getGeometryForIntersection(wktFirst);
final Geometry geometry2 = this.getGeometryForIntersection(wktSecond);
return geometry1.intersection(geometry2).getCoordinates();
}
catch (final ParseException e)
Expand All @@ -304,12 +296,13 @@ private Coordinate[] getIntersectionPoints(final String wktFirst,
}
}

private Geometry getGeometryForIntersection(String wktFirst) throws ParseException
private Geometry getGeometryForIntersection(final String wktFirst) throws ParseException
{

final WKTReader wktReader = new WKTReader();
Geometry geometry1 = wktReader.read(wktFirst);
if (geometry1.getGeometryType().equals(Geometry.TYPENAME_POLYGON)) {
if (geometry1.getGeometryType().equals(Geometry.TYPENAME_POLYGON))
{
geometry1 = geometry1.getBoundary();
}
return geometry1;
Expand Down Expand Up @@ -367,25 +360,29 @@ public boolean isCrossingNotTouching(final String wktFirst,
{
final Geometry geometry1 = wktReader.read(wktFirst);
final Geometry geometry2 = wktReader.read(wktSecond);
if(geometry1.equals(geometry2)){
if(geometry1.equals(geometry2))
{
return false;
}
if(anyGeometryInvalid(geometry1, geometry2)){
if(this.anyGeometryInvalid(geometry1, geometry2))
{
return false;
}
return isIntersectingNotTouching(geometry1, geometry2);
return this.isIntersectingNotTouching(geometry1, geometry2);
}
catch (final ParseException e)
{
return false;
}
}

private boolean anyGeometryInvalid(Geometry geometry1, Geometry geometry2) {
private boolean anyGeometryInvalid(final Geometry geometry1, final Geometry geometry2)
{
return !geometry1.isValid() || !geometry1.isSimple() || !geometry2.isValid() || !geometry2.isSimple();
}

private boolean isIntersectingNotTouching(final Geometry geometry1, final Geometry geometry2){
private boolean isIntersectingNotTouching(final Geometry geometry1, final Geometry geometry2)
{
return geometry1.intersects(geometry2) &&
(geometry1.crosses(geometry2) || (geometry1.overlaps(geometry2) && !this.isGeometryPairOfLineType(geometry1, geometry2)));
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,38 +1,48 @@
package org.openstreetmap.atlas.checks.validation.intersections;

import java.util.Set;

import org.openstreetmap.atlas.geography.Rectangle;
import org.openstreetmap.atlas.geography.atlas.items.AtlasEntity;

import java.util.Set;


public class BoundaryPart {
/**
* @author srachanski
*/
public class BoundaryPart
{

private final Set<String> boundaryTags;
private final AtlasEntity atlasEntity;

public BoundaryPart(AtlasEntity entity, Set<String> boundaryTags) {
public BoundaryPart(final AtlasEntity entity, final Set<String> boundaryTags)
{
this.atlasEntity = entity;
this.boundaryTags = boundaryTags;
}

public AtlasEntity getAtlasEntity() {
return atlasEntity;
public AtlasEntity getAtlasEntity()
{
return this.atlasEntity;
}

public Rectangle getBounds() {
return atlasEntity.bounds();
public Rectangle getBounds()
{
return this.atlasEntity.bounds();
}

public long getOsmIdentifier() {
return atlasEntity.getOsmIdentifier();
public long getOsmIdentifier()
{
return this.atlasEntity.getOsmIdentifier();
}

public String getWktGeometry() {
return atlasEntity.toWkt();
public String getWktGeometry()
{
return this.atlasEntity.toWkt();
}

public Set<String> getBoundaryTags() {
return boundaryTags;
public Set<String> getBoundaryTags()
{
return this.boundaryTags;
}
}
Original file line number Diff line number Diff line change
@@ -1,45 +1,48 @@
package org.openstreetmap.atlas.checks.validation.intersections;

import org.openstreetmap.atlas.geography.atlas.items.AtlasObject;
import org.openstreetmap.atlas.geography.atlas.items.LineItem;
import org.openstreetmap.atlas.geography.atlas.items.Relation;

import java.util.HashSet;
import java.util.Map;
import java.util.Set;
import java.util.stream.Collectors;

public class RelationBoundary {
import org.openstreetmap.atlas.geography.atlas.items.Relation;

/**
* @author srachanski
*/
public class RelationBoundary
{

private final Map<String, Relation> tagToRelation;
private final Set<BoundaryPart> boundaryParts;
// private final Set<AtlasObject> boundaryObjects;

public RelationBoundary(Map<String, Relation> tagToRelation, Set<BoundaryPart> boundaryParts) {
public RelationBoundary(final Map<String, Relation> tagToRelation, final Set<BoundaryPart> boundaryParts)
{
this.tagToRelation = tagToRelation;
this.boundaryParts = boundaryParts;
// this.boundaryObjects = boundaryParts.stream()
// .map(boundaryPart -> boundaryPart.get)
}

public Map<String, Relation> getTagToRelation() {
return tagToRelation;
public Map<String, Relation> getTagToRelation()
{
return this.tagToRelation;
}

public Set<BoundaryPart> getBoundaryParts() {
return boundaryParts;
public Set<BoundaryPart> getBoundaryParts()
{
return this.boundaryParts;
}

public Set<Relation> getRelationsByBoundaryTags(Set<String> tags){
return tagToRelation.keySet()
public Set<Relation> getRelationsByBoundaryTags(final Set<String> tags)
{
return this.tagToRelation.keySet()
.stream()
.filter(tags::contains)
.map(tagToRelation::get)
.map(this.tagToRelation::get)
.collect(Collectors.toSet());
}

public boolean containsRelationId(long osmIdentifier) {
return tagToRelation.values()
public boolean containsRelationId(final long osmIdentifier)
{
return this.tagToRelation.values()
.stream()
.map(Relation::getOsmIdentifier)
.anyMatch(id -> id == osmIdentifier);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,9 @@ public class UnwalkableWaysCheck extends BaseCheck<Long>
private static final Logger logger = LoggerFactory.getLogger(UnwalkableWaysCheck.class);
// Instructions
private static final List<String> FALLBACK_INSTRUCTIONS = Collections
.singletonList("");
.singletonList("Way {0,number,#} may be unwalkable and needs verification if safe "
+ "pedestrian crossing exists. If it does, it should be marked ‘foot=yes’. If "
+ "safe pedestrian crossing does not exist, the Way should be marked ‘foot=no'.");
// The minimum highway type considered for potential dual carriageways
private static final HighwayTag MINIMUM_HIGHWAY_TYPE_DEFAULT = HighwayTag.PRIMARY;
private static final List<String> DEFAULT_WALKWAY_TAGS = Arrays.asList(
Expand Down

0 comments on commit 735b45c

Please sign in to comment.