public static MultiDimensionalPositions.Builder builder(MultiDimensionalPositions positions) { return builder().addAreaPositions(positions.children); }
public static MultiDimensionalPositions.Builder builder(MultiDimensionalPositions positions) { return builder().addAreaPositions(positions.children); }
static PositionsBuilder builderOf(Positions p) { if(p instanceof SinglePosition) { return LinearPositions.builder(); } else if (p instanceof LinearPositions) { return AreaPositions.builder(); } else if (p instanceof AreaPositions) { return MultiDimensionalPositions.builder(); } else { throw new IllegalArgumentException("No builder can be supplied for Positions " + p); } }
static PositionsBuilder builderOf(Positions p) { if(p instanceof SinglePosition) { return LinearPositions.builder(); } else if (p instanceof LinearPositions) { return AreaPositions.builder(); } else if (p instanceof AreaPositions) { return MultiDimensionalPositions.builder(); } else { throw new IllegalArgumentException("No builder can be supplied for Positions " + p); } }
/** * Creates a MultiPolygon from the given {@link Polygon} sequence. * * @param polygons The {@link Polygon} Iterable. * @return MultiPolygon */ public static MultiPolygon of(Iterable<Polygon> polygons) { MultiDimensionalPositions.Builder positionsBuilder = MultiDimensionalPositions.builder(); for(Polygon polygon : polygons) { positionsBuilder.addAreaPosition(polygon.positions()); } return new MultiPolygon(positionsBuilder.build()); }
/** * Creates a MultiPolygon from the given {@link Polygon} sequence. * * @param polygons The {@link Polygon} Iterable. * @return MultiPolygon */ public static MultiPolygon of(Iterable<Polygon> polygons) { MultiDimensionalPositions.Builder positionsBuilder = MultiDimensionalPositions.builder(); for(Polygon polygon : polygons) { positionsBuilder.addAreaPosition(polygon.positions()); } return new MultiPolygon(positionsBuilder.build()); }
@Override public PositionsBuilder addChild(Positions p) { if(p instanceof LinearPositions) { return addLinearPosition((LinearPositions)p); } else if (p instanceof SinglePosition) { return addLinearPosition(LinearPositions.builder().addSinglePosition((SinglePosition) p).build()); } else if (p instanceof AreaPositions) { return MultiDimensionalPositions.builder().addAreaPosition(this.build()).addChild(p); } else { throw new IllegalArgumentException("The position " + p + "cannot be a child of AreaPosition"); } }
@Override public PositionsBuilder addChild(Positions p) { if(p instanceof LinearPositions) { return addLinearPosition((LinearPositions)p); } else if (p instanceof SinglePosition) { return addLinearPosition(LinearPositions.builder().addSinglePosition((SinglePosition) p).build()); } else if (p instanceof AreaPositions) { return MultiDimensionalPositions.builder().addAreaPosition(this.build()).addChild(p); } else { throw new IllegalArgumentException("The position " + p + "cannot be a child of AreaPosition"); } }
/** * Merge this Positions with another one. If the given {@link Positions} is: * - SinglePosition, it will raise an IllegalArgumentException. * - LinearPositions, it will return a new AreaPosition by appending the given LinearPositions to this. * - AreaPositions, it will return a new MultiDimensionalPositions composed by this and the given AreaPositions, * in order. * - Any other, it delegates to the other the merge logic. * * @param other Positions instance to merge with. * * @return Positions results of merging. */ @Override public Positions merge(Positions other) { if (other instanceof SinglePosition) { throw new IllegalArgumentException("Cannot merge single position and area children"); } else if (other instanceof LinearPositions) { LinearPositions that = (LinearPositions) other; return builder().addLinearPosition(that).build(); } else if (other instanceof AreaPositions) { AreaPositions that = (AreaPositions) other; return MultiDimensionalPositions.builder().addAreaPosition(this).addAreaPosition(that).build(); } else { return other.merge(this); } }
/** * Merge this Positions with another one. If the given {@link Positions} is: * - SinglePosition, it will raise an IllegalArgumentException. * - LinearPositions, it will return a new AreaPosition by appending the given LinearPositions to this. * - AreaPositions, it will return a new MultiDimensionalPositions composed by this and the given AreaPositions, * in order. * - Any other, it delegates to the other the merge logic. * * @param other Positions instance to merge with. * * @return Positions results of merging. */ @Override public Positions merge(Positions other) { if (other instanceof SinglePosition) { throw new IllegalArgumentException("Cannot merge single position and area children"); } else if (other instanceof LinearPositions) { LinearPositions that = (LinearPositions) other; return builder().addLinearPosition(that).build(); } else if (other instanceof AreaPositions) { AreaPositions that = (AreaPositions) other; return MultiDimensionalPositions.builder().addAreaPosition(this).addAreaPosition(that).build(); } else { return other.merge(this); } }