repo_name stringlengths 7 104 | file_path stringlengths 13 198 | context stringlengths 67 7.15k | import_statement stringlengths 16 4.43k | code stringlengths 40 6.98k | prompt stringlengths 227 8.27k | next_line stringlengths 8 795 |
|---|---|---|---|---|---|---|
mokszr/ultimate-geojson | ugeojson-builder/src/main/java/org/ugeojson/builder/geometry/MultiPolygonBuilder.java | // Path: ugeojson-builder/src/main/java/org/ugeojson/builder/common/BuilderConstants.java
// public interface BuilderConstants {
//
// public static final String OPEN_BRACKET = "[";
// public static final String CLOSE_BRACKET = "]";
// public static final String OPEN_CURLY_BRACE = "{";
// public static final String CLOSE_CURLY_BRACE = "}";
//
// public static final String COMMA_SPACE = ", ";
// public static final String COMMA = ",";
// public static final String SPACE = " ";
// public static final String COMMA_NEWLINE = ",\n";
// public static final String NEWLINE = "\n";
// public static final String DOUBLE_QUOTE = "\"";
// public static final String NULL_VALUE = "null";
// public static final String TAB_SPACE = " ";
// public static final String EMPTY = "";
//
// public static final String TYPE_SPACE = "\"type\": ";
// public static final String COORDINATES_SPACE = "\"coordinates\": ";
// public static final String GEOMETRIES_SPACE = "\"geometries\": ";
// public static final String GEOMETRY_SPACE = "\"geometry\": ";
// public static final String PROPERTIES_SPACE = "\"properties\": ";
// public static final String ID_SPACE = "\"id\": ";
// public static final String FEATURES_SPACE = "\"features\": ";
// public static final String BBOX_SPACE = "\"bbox\": ";
// }
//
// Path: ugeojson-model/src/main/java/org/ugeojson/model/GeoJSONObjectTypeEnum.java
// public enum GeoJSONObjectTypeEnum {
//
// Point(PointDto.class), MultiPoint(MultiPointDto.class), LineString(LineStringDto.class), MultiLineString(
// MultiLineStringDto.class), Polygon(PolygonDto.class), MultiPolygon(
// MultiPolygonDto.class), GeometryCollection(GeometryCollectionDto.class), Feature(
// FeatureDto.class), FeatureCollection(FeatureCollectionDto.class);
//
// private final Class dtoClass;
//
// private GeoJSONObjectTypeEnum(Class dtoClass) {
// this.dtoClass = dtoClass;
// }
//
// public Class getDtoClass() {
// return dtoClass;
// }
// }
//
// Path: ugeojson-model/src/main/java/org/ugeojson/model/geometry/LineStringDto.java
// public class LineStringDto extends GeometryDto {
//
// private static final long serialVersionUID = 1L;
//
// private List<PositionDto> positions;
//
// public LineStringDto(){
// }
//
// public LineStringDto(List<PositionDto> positions){
// this.positions = new ArrayList<>();
// for (PositionDto positionDto : positions) {
// this.positions.add(new PositionDto(positionDto));
// }
// }
//
// public List<PositionDto> getPositions() {
// return positions;
// }
//
// public void setPositions(List<PositionDto> positions) {
// this.positions = positions;
// }
//
// @Override
// public GeoJSONObjectTypeEnum getGeoJSONObjectType() {
// return GeoJSONObjectTypeEnum.LineString;
// }
// }
//
// Path: ugeojson-model/src/main/java/org/ugeojson/model/geometry/MultiPolygonDto.java
// public class MultiPolygonDto extends GeometryDto {
//
// private static final long serialVersionUID = 1L;
//
// private List<PolygonDto> polygons;
//
// public List<PolygonDto> getPolygons() {
// return polygons;
// }
//
// public void setPolygons(List<PolygonDto> polygons) {
// this.polygons = polygons;
// }
//
// @Override
// public GeoJSONObjectTypeEnum getGeoJSONObjectType() {
// return GeoJSONObjectTypeEnum.MultiPolygon;
// }
// }
//
// Path: ugeojson-model/src/main/java/org/ugeojson/model/geometry/PolygonDto.java
// public class PolygonDto extends GeometryDto {
//
// private static final long serialVersionUID = 1L;
//
// private List<LineStringDto> linearRings;
//
// @Override
// public GeoJSONObjectTypeEnum getGeoJSONObjectType() {
// return GeoJSONObjectTypeEnum.Polygon;
// }
//
// public List<LineStringDto> getLinearRings() {
// return linearRings;
// }
//
// public void setLinearRings(List<LineStringDto> linearRings) {
// this.linearRings = linearRings;
// }
//
// }
| import java.util.List;
import org.ugeojson.builder.common.BuilderConstants;
import org.ugeojson.model.GeoJSONObjectTypeEnum;
import org.ugeojson.model.geometry.LineStringDto;
import org.ugeojson.model.geometry.MultiPolygonDto;
import org.ugeojson.model.geometry.PolygonDto; | package org.ugeojson.builder.geometry;
/**
* @author moksuzer
*
*/
public class MultiPolygonBuilder extends GeometryBuilder<MultiPolygonDto> {
private static final MultiPolygonBuilder INSTANCE = new MultiPolygonBuilder();
public static MultiPolygonBuilder getInstance() {
return INSTANCE;
}
private MultiPolygonBuilder() {
}
/*
* (non-Javadoc)
*
* @see
* org.ugeojson.builder.geometry.GeometryBuilder#toGeometryGeoJSON(com
* .erumi.ugeojson.model.geometry.GeometryDto)
*/
@Override
public String toGeoJSON(MultiPolygonDto multiPolygon) {
if (multiPolygon == null || multiPolygon.getPolygons() == null || multiPolygon.getPolygons().isEmpty()) {
return BuilderConstants.NULL_VALUE;
}
| // Path: ugeojson-builder/src/main/java/org/ugeojson/builder/common/BuilderConstants.java
// public interface BuilderConstants {
//
// public static final String OPEN_BRACKET = "[";
// public static final String CLOSE_BRACKET = "]";
// public static final String OPEN_CURLY_BRACE = "{";
// public static final String CLOSE_CURLY_BRACE = "}";
//
// public static final String COMMA_SPACE = ", ";
// public static final String COMMA = ",";
// public static final String SPACE = " ";
// public static final String COMMA_NEWLINE = ",\n";
// public static final String NEWLINE = "\n";
// public static final String DOUBLE_QUOTE = "\"";
// public static final String NULL_VALUE = "null";
// public static final String TAB_SPACE = " ";
// public static final String EMPTY = "";
//
// public static final String TYPE_SPACE = "\"type\": ";
// public static final String COORDINATES_SPACE = "\"coordinates\": ";
// public static final String GEOMETRIES_SPACE = "\"geometries\": ";
// public static final String GEOMETRY_SPACE = "\"geometry\": ";
// public static final String PROPERTIES_SPACE = "\"properties\": ";
// public static final String ID_SPACE = "\"id\": ";
// public static final String FEATURES_SPACE = "\"features\": ";
// public static final String BBOX_SPACE = "\"bbox\": ";
// }
//
// Path: ugeojson-model/src/main/java/org/ugeojson/model/GeoJSONObjectTypeEnum.java
// public enum GeoJSONObjectTypeEnum {
//
// Point(PointDto.class), MultiPoint(MultiPointDto.class), LineString(LineStringDto.class), MultiLineString(
// MultiLineStringDto.class), Polygon(PolygonDto.class), MultiPolygon(
// MultiPolygonDto.class), GeometryCollection(GeometryCollectionDto.class), Feature(
// FeatureDto.class), FeatureCollection(FeatureCollectionDto.class);
//
// private final Class dtoClass;
//
// private GeoJSONObjectTypeEnum(Class dtoClass) {
// this.dtoClass = dtoClass;
// }
//
// public Class getDtoClass() {
// return dtoClass;
// }
// }
//
// Path: ugeojson-model/src/main/java/org/ugeojson/model/geometry/LineStringDto.java
// public class LineStringDto extends GeometryDto {
//
// private static final long serialVersionUID = 1L;
//
// private List<PositionDto> positions;
//
// public LineStringDto(){
// }
//
// public LineStringDto(List<PositionDto> positions){
// this.positions = new ArrayList<>();
// for (PositionDto positionDto : positions) {
// this.positions.add(new PositionDto(positionDto));
// }
// }
//
// public List<PositionDto> getPositions() {
// return positions;
// }
//
// public void setPositions(List<PositionDto> positions) {
// this.positions = positions;
// }
//
// @Override
// public GeoJSONObjectTypeEnum getGeoJSONObjectType() {
// return GeoJSONObjectTypeEnum.LineString;
// }
// }
//
// Path: ugeojson-model/src/main/java/org/ugeojson/model/geometry/MultiPolygonDto.java
// public class MultiPolygonDto extends GeometryDto {
//
// private static final long serialVersionUID = 1L;
//
// private List<PolygonDto> polygons;
//
// public List<PolygonDto> getPolygons() {
// return polygons;
// }
//
// public void setPolygons(List<PolygonDto> polygons) {
// this.polygons = polygons;
// }
//
// @Override
// public GeoJSONObjectTypeEnum getGeoJSONObjectType() {
// return GeoJSONObjectTypeEnum.MultiPolygon;
// }
// }
//
// Path: ugeojson-model/src/main/java/org/ugeojson/model/geometry/PolygonDto.java
// public class PolygonDto extends GeometryDto {
//
// private static final long serialVersionUID = 1L;
//
// private List<LineStringDto> linearRings;
//
// @Override
// public GeoJSONObjectTypeEnum getGeoJSONObjectType() {
// return GeoJSONObjectTypeEnum.Polygon;
// }
//
// public List<LineStringDto> getLinearRings() {
// return linearRings;
// }
//
// public void setLinearRings(List<LineStringDto> linearRings) {
// this.linearRings = linearRings;
// }
//
// }
// Path: ugeojson-builder/src/main/java/org/ugeojson/builder/geometry/MultiPolygonBuilder.java
import java.util.List;
import org.ugeojson.builder.common.BuilderConstants;
import org.ugeojson.model.GeoJSONObjectTypeEnum;
import org.ugeojson.model.geometry.LineStringDto;
import org.ugeojson.model.geometry.MultiPolygonDto;
import org.ugeojson.model.geometry.PolygonDto;
package org.ugeojson.builder.geometry;
/**
* @author moksuzer
*
*/
public class MultiPolygonBuilder extends GeometryBuilder<MultiPolygonDto> {
private static final MultiPolygonBuilder INSTANCE = new MultiPolygonBuilder();
public static MultiPolygonBuilder getInstance() {
return INSTANCE;
}
private MultiPolygonBuilder() {
}
/*
* (non-Javadoc)
*
* @see
* org.ugeojson.builder.geometry.GeometryBuilder#toGeometryGeoJSON(com
* .erumi.ugeojson.model.geometry.GeometryDto)
*/
@Override
public String toGeoJSON(MultiPolygonDto multiPolygon) {
if (multiPolygon == null || multiPolygon.getPolygons() == null || multiPolygon.getPolygons().isEmpty()) {
return BuilderConstants.NULL_VALUE;
}
| List<PolygonDto> polygons = multiPolygon.getPolygons(); |
mokszr/ultimate-geojson | ugeojson-builder/src/main/java/org/ugeojson/builder/geometry/MultiPolygonBuilder.java | // Path: ugeojson-builder/src/main/java/org/ugeojson/builder/common/BuilderConstants.java
// public interface BuilderConstants {
//
// public static final String OPEN_BRACKET = "[";
// public static final String CLOSE_BRACKET = "]";
// public static final String OPEN_CURLY_BRACE = "{";
// public static final String CLOSE_CURLY_BRACE = "}";
//
// public static final String COMMA_SPACE = ", ";
// public static final String COMMA = ",";
// public static final String SPACE = " ";
// public static final String COMMA_NEWLINE = ",\n";
// public static final String NEWLINE = "\n";
// public static final String DOUBLE_QUOTE = "\"";
// public static final String NULL_VALUE = "null";
// public static final String TAB_SPACE = " ";
// public static final String EMPTY = "";
//
// public static final String TYPE_SPACE = "\"type\": ";
// public static final String COORDINATES_SPACE = "\"coordinates\": ";
// public static final String GEOMETRIES_SPACE = "\"geometries\": ";
// public static final String GEOMETRY_SPACE = "\"geometry\": ";
// public static final String PROPERTIES_SPACE = "\"properties\": ";
// public static final String ID_SPACE = "\"id\": ";
// public static final String FEATURES_SPACE = "\"features\": ";
// public static final String BBOX_SPACE = "\"bbox\": ";
// }
//
// Path: ugeojson-model/src/main/java/org/ugeojson/model/GeoJSONObjectTypeEnum.java
// public enum GeoJSONObjectTypeEnum {
//
// Point(PointDto.class), MultiPoint(MultiPointDto.class), LineString(LineStringDto.class), MultiLineString(
// MultiLineStringDto.class), Polygon(PolygonDto.class), MultiPolygon(
// MultiPolygonDto.class), GeometryCollection(GeometryCollectionDto.class), Feature(
// FeatureDto.class), FeatureCollection(FeatureCollectionDto.class);
//
// private final Class dtoClass;
//
// private GeoJSONObjectTypeEnum(Class dtoClass) {
// this.dtoClass = dtoClass;
// }
//
// public Class getDtoClass() {
// return dtoClass;
// }
// }
//
// Path: ugeojson-model/src/main/java/org/ugeojson/model/geometry/LineStringDto.java
// public class LineStringDto extends GeometryDto {
//
// private static final long serialVersionUID = 1L;
//
// private List<PositionDto> positions;
//
// public LineStringDto(){
// }
//
// public LineStringDto(List<PositionDto> positions){
// this.positions = new ArrayList<>();
// for (PositionDto positionDto : positions) {
// this.positions.add(new PositionDto(positionDto));
// }
// }
//
// public List<PositionDto> getPositions() {
// return positions;
// }
//
// public void setPositions(List<PositionDto> positions) {
// this.positions = positions;
// }
//
// @Override
// public GeoJSONObjectTypeEnum getGeoJSONObjectType() {
// return GeoJSONObjectTypeEnum.LineString;
// }
// }
//
// Path: ugeojson-model/src/main/java/org/ugeojson/model/geometry/MultiPolygonDto.java
// public class MultiPolygonDto extends GeometryDto {
//
// private static final long serialVersionUID = 1L;
//
// private List<PolygonDto> polygons;
//
// public List<PolygonDto> getPolygons() {
// return polygons;
// }
//
// public void setPolygons(List<PolygonDto> polygons) {
// this.polygons = polygons;
// }
//
// @Override
// public GeoJSONObjectTypeEnum getGeoJSONObjectType() {
// return GeoJSONObjectTypeEnum.MultiPolygon;
// }
// }
//
// Path: ugeojson-model/src/main/java/org/ugeojson/model/geometry/PolygonDto.java
// public class PolygonDto extends GeometryDto {
//
// private static final long serialVersionUID = 1L;
//
// private List<LineStringDto> linearRings;
//
// @Override
// public GeoJSONObjectTypeEnum getGeoJSONObjectType() {
// return GeoJSONObjectTypeEnum.Polygon;
// }
//
// public List<LineStringDto> getLinearRings() {
// return linearRings;
// }
//
// public void setLinearRings(List<LineStringDto> linearRings) {
// this.linearRings = linearRings;
// }
//
// }
| import java.util.List;
import org.ugeojson.builder.common.BuilderConstants;
import org.ugeojson.model.GeoJSONObjectTypeEnum;
import org.ugeojson.model.geometry.LineStringDto;
import org.ugeojson.model.geometry.MultiPolygonDto;
import org.ugeojson.model.geometry.PolygonDto; | package org.ugeojson.builder.geometry;
/**
* @author moksuzer
*
*/
public class MultiPolygonBuilder extends GeometryBuilder<MultiPolygonDto> {
private static final MultiPolygonBuilder INSTANCE = new MultiPolygonBuilder();
public static MultiPolygonBuilder getInstance() {
return INSTANCE;
}
private MultiPolygonBuilder() {
}
/*
* (non-Javadoc)
*
* @see
* org.ugeojson.builder.geometry.GeometryBuilder#toGeometryGeoJSON(com
* .erumi.ugeojson.model.geometry.GeometryDto)
*/
@Override
public String toGeoJSON(MultiPolygonDto multiPolygon) {
if (multiPolygon == null || multiPolygon.getPolygons() == null || multiPolygon.getPolygons().isEmpty()) {
return BuilderConstants.NULL_VALUE;
}
List<PolygonDto> polygons = multiPolygon.getPolygons();
for (PolygonDto polygonDto : polygons) {
checkAndCorrectLinearRing(polygonDto);
}
StringBuilder builder = initializeBuilder(); | // Path: ugeojson-builder/src/main/java/org/ugeojson/builder/common/BuilderConstants.java
// public interface BuilderConstants {
//
// public static final String OPEN_BRACKET = "[";
// public static final String CLOSE_BRACKET = "]";
// public static final String OPEN_CURLY_BRACE = "{";
// public static final String CLOSE_CURLY_BRACE = "}";
//
// public static final String COMMA_SPACE = ", ";
// public static final String COMMA = ",";
// public static final String SPACE = " ";
// public static final String COMMA_NEWLINE = ",\n";
// public static final String NEWLINE = "\n";
// public static final String DOUBLE_QUOTE = "\"";
// public static final String NULL_VALUE = "null";
// public static final String TAB_SPACE = " ";
// public static final String EMPTY = "";
//
// public static final String TYPE_SPACE = "\"type\": ";
// public static final String COORDINATES_SPACE = "\"coordinates\": ";
// public static final String GEOMETRIES_SPACE = "\"geometries\": ";
// public static final String GEOMETRY_SPACE = "\"geometry\": ";
// public static final String PROPERTIES_SPACE = "\"properties\": ";
// public static final String ID_SPACE = "\"id\": ";
// public static final String FEATURES_SPACE = "\"features\": ";
// public static final String BBOX_SPACE = "\"bbox\": ";
// }
//
// Path: ugeojson-model/src/main/java/org/ugeojson/model/GeoJSONObjectTypeEnum.java
// public enum GeoJSONObjectTypeEnum {
//
// Point(PointDto.class), MultiPoint(MultiPointDto.class), LineString(LineStringDto.class), MultiLineString(
// MultiLineStringDto.class), Polygon(PolygonDto.class), MultiPolygon(
// MultiPolygonDto.class), GeometryCollection(GeometryCollectionDto.class), Feature(
// FeatureDto.class), FeatureCollection(FeatureCollectionDto.class);
//
// private final Class dtoClass;
//
// private GeoJSONObjectTypeEnum(Class dtoClass) {
// this.dtoClass = dtoClass;
// }
//
// public Class getDtoClass() {
// return dtoClass;
// }
// }
//
// Path: ugeojson-model/src/main/java/org/ugeojson/model/geometry/LineStringDto.java
// public class LineStringDto extends GeometryDto {
//
// private static final long serialVersionUID = 1L;
//
// private List<PositionDto> positions;
//
// public LineStringDto(){
// }
//
// public LineStringDto(List<PositionDto> positions){
// this.positions = new ArrayList<>();
// for (PositionDto positionDto : positions) {
// this.positions.add(new PositionDto(positionDto));
// }
// }
//
// public List<PositionDto> getPositions() {
// return positions;
// }
//
// public void setPositions(List<PositionDto> positions) {
// this.positions = positions;
// }
//
// @Override
// public GeoJSONObjectTypeEnum getGeoJSONObjectType() {
// return GeoJSONObjectTypeEnum.LineString;
// }
// }
//
// Path: ugeojson-model/src/main/java/org/ugeojson/model/geometry/MultiPolygonDto.java
// public class MultiPolygonDto extends GeometryDto {
//
// private static final long serialVersionUID = 1L;
//
// private List<PolygonDto> polygons;
//
// public List<PolygonDto> getPolygons() {
// return polygons;
// }
//
// public void setPolygons(List<PolygonDto> polygons) {
// this.polygons = polygons;
// }
//
// @Override
// public GeoJSONObjectTypeEnum getGeoJSONObjectType() {
// return GeoJSONObjectTypeEnum.MultiPolygon;
// }
// }
//
// Path: ugeojson-model/src/main/java/org/ugeojson/model/geometry/PolygonDto.java
// public class PolygonDto extends GeometryDto {
//
// private static final long serialVersionUID = 1L;
//
// private List<LineStringDto> linearRings;
//
// @Override
// public GeoJSONObjectTypeEnum getGeoJSONObjectType() {
// return GeoJSONObjectTypeEnum.Polygon;
// }
//
// public List<LineStringDto> getLinearRings() {
// return linearRings;
// }
//
// public void setLinearRings(List<LineStringDto> linearRings) {
// this.linearRings = linearRings;
// }
//
// }
// Path: ugeojson-builder/src/main/java/org/ugeojson/builder/geometry/MultiPolygonBuilder.java
import java.util.List;
import org.ugeojson.builder.common.BuilderConstants;
import org.ugeojson.model.GeoJSONObjectTypeEnum;
import org.ugeojson.model.geometry.LineStringDto;
import org.ugeojson.model.geometry.MultiPolygonDto;
import org.ugeojson.model.geometry.PolygonDto;
package org.ugeojson.builder.geometry;
/**
* @author moksuzer
*
*/
public class MultiPolygonBuilder extends GeometryBuilder<MultiPolygonDto> {
private static final MultiPolygonBuilder INSTANCE = new MultiPolygonBuilder();
public static MultiPolygonBuilder getInstance() {
return INSTANCE;
}
private MultiPolygonBuilder() {
}
/*
* (non-Javadoc)
*
* @see
* org.ugeojson.builder.geometry.GeometryBuilder#toGeometryGeoJSON(com
* .erumi.ugeojson.model.geometry.GeometryDto)
*/
@Override
public String toGeoJSON(MultiPolygonDto multiPolygon) {
if (multiPolygon == null || multiPolygon.getPolygons() == null || multiPolygon.getPolygons().isEmpty()) {
return BuilderConstants.NULL_VALUE;
}
List<PolygonDto> polygons = multiPolygon.getPolygons();
for (PolygonDto polygonDto : polygons) {
checkAndCorrectLinearRing(polygonDto);
}
StringBuilder builder = initializeBuilder(); | buildTypePart(builder, GeoJSONObjectTypeEnum.MultiPolygon); |
mokszr/ultimate-geojson | ugeojson-parser/src/main/java/org/ugeojson/parser/deserializer/MultiPointDeserializer.java | // Path: ugeojson-model/src/main/java/org/ugeojson/model/PositionDto.java
// public class PositionDto implements Serializable {
//
// private static final long serialVersionUID = 1L;
//
// private double[] numbers;
//
// /**
// * This constructor initializes numbers field to hold two double numbers. Do
// * not use this constructor if you need the third elevation parameter.
// */
// public PositionDto() {
// this.numbers = new double[2];
// }
//
// /**
// * Simple coordinate position constructor
// *
// * @param longitude
// * @param latitude
// */
// public PositionDto(double longitude, double latitude) {
// this.numbers = new double[] { longitude, latitude };
// }
//
// /**
// * Use this constructor if you need elevation parameter
// *
// * @param longitude
// * @param latitude
// * @param elevation
// */
// public PositionDto(double longitude, double latitude, double elevation) {
// this.numbers = new double[] { longitude, latitude, elevation };
// }
//
// /**
// * Copy constructor
// *
// * @param position
// */
// public PositionDto(PositionDto position) {
// if (position != null) {
// double[] copyNumbers = position.getNumbers();
// this.numbers = new double[copyNumbers.length];
// for (int i = 0; i < copyNumbers.length; i++) {
// this.numbers[i] = copyNumbers[i];
// }
// }
// }
//
// @Override
// public String toString() {
// if (numbers == null) {
// return "null numbers[]";
// }
// StringBuilder value = new StringBuilder("[");
// for (int i = 0; i < numbers.length; i++) {
// value.append(numbers[i]);
// if (i < numbers.length - 1) {
// value.append(", ");
// }
// }
// value.append("]");
// return value.toString();
// }
//
// public void setLongitude(double longitude) {
// this.numbers[0] = longitude;
// }
//
// public double getLongitude() {
// return numbers[0];
// }
//
// public void setLatitude(double latitude) {
// this.numbers[1] = latitude;
// }
//
// public double getLatitude() {
// return numbers[1];
// }
//
// public void setElevation(double elevation) {
// this.numbers[2] = elevation;
// }
//
// public double getElevation() {
// return numbers[2];
// }
//
// public double[] getNumbers() {
// return numbers;
// }
//
// public void setNumbers(double[] numbers) {
// this.numbers = numbers;
// }
// }
//
// Path: ugeojson-model/src/main/java/org/ugeojson/model/geometry/MultiPointDto.java
// public class MultiPointDto extends GeometryDto {
//
// private static final long serialVersionUID = 1L;
//
// private List<PositionDto> positions;
//
// public List<PositionDto> getPositions() {
// return positions;
// }
//
// public void setPositions(List<PositionDto> positions) {
// this.positions = positions;
// }
//
// @Override
// public GeoJSONObjectTypeEnum getGeoJSONObjectType() {
// return GeoJSONObjectTypeEnum.MultiPoint;
// }
// }
//
// Path: ugeojson-parser/src/main/java/org/ugeojson/parser/util/BoundingBoxParser.java
// public class BoundingBoxParser {
//
// private static final int TWO_DIMENSIONAL_BBOX_LENGTH = 4;
//
// private BoundingBoxParser() {
// }
//
// public static BoundingBoxDto parseBbox(JsonObject asJsonObject, JsonDeserializationContext context) {
// BoundingBoxDto bboxDto = null;
// JsonElement bboxElement = asJsonObject.get("bbox");
// if (bboxElement != null) {
// double[] bbox = context.deserialize(bboxElement, double[].class);
// bboxDto = new BoundingBoxDto();
// if (bbox.length == TWO_DIMENSIONAL_BBOX_LENGTH) {
// bboxDto.setSouthWestCorner(new PositionDto(bbox[0], bbox[1]));
// bboxDto.setNorthEastCorner(new PositionDto(bbox[2], bbox[3]));
// } else {
// bboxDto.setSouthWestCorner(new PositionDto(bbox[0], bbox[1], bbox[2]));
// bboxDto.setNorthEastCorner(new PositionDto(bbox[3], bbox[4], bbox[5]));
// }
//
// }
// return bboxDto;
// }
//
// }
| import java.lang.reflect.Type;
import java.util.ArrayList;
import java.util.List;
import org.ugeojson.model.PositionDto;
import org.ugeojson.model.geometry.MultiPointDto;
import org.ugeojson.parser.util.BoundingBoxParser;
import com.google.gson.JsonArray;
import com.google.gson.JsonDeserializationContext;
import com.google.gson.JsonDeserializer;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject; | package org.ugeojson.parser.deserializer;
/**
* Deserializer for MultiPoint
*
* @author moksuzer
*
*/
public class MultiPointDeserializer implements JsonDeserializer<MultiPointDto> {
@Override
public MultiPointDto deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) {
MultiPointDto dto = new MultiPointDto(); | // Path: ugeojson-model/src/main/java/org/ugeojson/model/PositionDto.java
// public class PositionDto implements Serializable {
//
// private static final long serialVersionUID = 1L;
//
// private double[] numbers;
//
// /**
// * This constructor initializes numbers field to hold two double numbers. Do
// * not use this constructor if you need the third elevation parameter.
// */
// public PositionDto() {
// this.numbers = new double[2];
// }
//
// /**
// * Simple coordinate position constructor
// *
// * @param longitude
// * @param latitude
// */
// public PositionDto(double longitude, double latitude) {
// this.numbers = new double[] { longitude, latitude };
// }
//
// /**
// * Use this constructor if you need elevation parameter
// *
// * @param longitude
// * @param latitude
// * @param elevation
// */
// public PositionDto(double longitude, double latitude, double elevation) {
// this.numbers = new double[] { longitude, latitude, elevation };
// }
//
// /**
// * Copy constructor
// *
// * @param position
// */
// public PositionDto(PositionDto position) {
// if (position != null) {
// double[] copyNumbers = position.getNumbers();
// this.numbers = new double[copyNumbers.length];
// for (int i = 0; i < copyNumbers.length; i++) {
// this.numbers[i] = copyNumbers[i];
// }
// }
// }
//
// @Override
// public String toString() {
// if (numbers == null) {
// return "null numbers[]";
// }
// StringBuilder value = new StringBuilder("[");
// for (int i = 0; i < numbers.length; i++) {
// value.append(numbers[i]);
// if (i < numbers.length - 1) {
// value.append(", ");
// }
// }
// value.append("]");
// return value.toString();
// }
//
// public void setLongitude(double longitude) {
// this.numbers[0] = longitude;
// }
//
// public double getLongitude() {
// return numbers[0];
// }
//
// public void setLatitude(double latitude) {
// this.numbers[1] = latitude;
// }
//
// public double getLatitude() {
// return numbers[1];
// }
//
// public void setElevation(double elevation) {
// this.numbers[2] = elevation;
// }
//
// public double getElevation() {
// return numbers[2];
// }
//
// public double[] getNumbers() {
// return numbers;
// }
//
// public void setNumbers(double[] numbers) {
// this.numbers = numbers;
// }
// }
//
// Path: ugeojson-model/src/main/java/org/ugeojson/model/geometry/MultiPointDto.java
// public class MultiPointDto extends GeometryDto {
//
// private static final long serialVersionUID = 1L;
//
// private List<PositionDto> positions;
//
// public List<PositionDto> getPositions() {
// return positions;
// }
//
// public void setPositions(List<PositionDto> positions) {
// this.positions = positions;
// }
//
// @Override
// public GeoJSONObjectTypeEnum getGeoJSONObjectType() {
// return GeoJSONObjectTypeEnum.MultiPoint;
// }
// }
//
// Path: ugeojson-parser/src/main/java/org/ugeojson/parser/util/BoundingBoxParser.java
// public class BoundingBoxParser {
//
// private static final int TWO_DIMENSIONAL_BBOX_LENGTH = 4;
//
// private BoundingBoxParser() {
// }
//
// public static BoundingBoxDto parseBbox(JsonObject asJsonObject, JsonDeserializationContext context) {
// BoundingBoxDto bboxDto = null;
// JsonElement bboxElement = asJsonObject.get("bbox");
// if (bboxElement != null) {
// double[] bbox = context.deserialize(bboxElement, double[].class);
// bboxDto = new BoundingBoxDto();
// if (bbox.length == TWO_DIMENSIONAL_BBOX_LENGTH) {
// bboxDto.setSouthWestCorner(new PositionDto(bbox[0], bbox[1]));
// bboxDto.setNorthEastCorner(new PositionDto(bbox[2], bbox[3]));
// } else {
// bboxDto.setSouthWestCorner(new PositionDto(bbox[0], bbox[1], bbox[2]));
// bboxDto.setNorthEastCorner(new PositionDto(bbox[3], bbox[4], bbox[5]));
// }
//
// }
// return bboxDto;
// }
//
// }
// Path: ugeojson-parser/src/main/java/org/ugeojson/parser/deserializer/MultiPointDeserializer.java
import java.lang.reflect.Type;
import java.util.ArrayList;
import java.util.List;
import org.ugeojson.model.PositionDto;
import org.ugeojson.model.geometry.MultiPointDto;
import org.ugeojson.parser.util.BoundingBoxParser;
import com.google.gson.JsonArray;
import com.google.gson.JsonDeserializationContext;
import com.google.gson.JsonDeserializer;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
package org.ugeojson.parser.deserializer;
/**
* Deserializer for MultiPoint
*
* @author moksuzer
*
*/
public class MultiPointDeserializer implements JsonDeserializer<MultiPointDto> {
@Override
public MultiPointDto deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) {
MultiPointDto dto = new MultiPointDto(); | List<PositionDto> positions = new ArrayList<>(); |
mokszr/ultimate-geojson | ugeojson-builder/src/test/java/org/ugeojson/builder/geometry/PositionBuilderShould.java | // Path: ugeojson-builder/src/main/java/org/ugeojson/builder/geometry/PositionBuilder.java
// public class PositionBuilder {
//
// private static final int MINIMUM_POSITION_DIMENSION = 2;
//
// private static final PositionBuilder INSTANCE = new PositionBuilder();
//
//
// public static PositionBuilder getInstance(){
// return INSTANCE;
// }
//
// private PositionBuilder(){
// }
//
// public String position(PositionDto position) {
// if(position == null || position.getNumbers().length < MINIMUM_POSITION_DIMENSION){
// throw new InvalidPositionDtoException(position);
// }
//
// double[] numbers = position.getNumbers();
// StringBuilder builder = new StringBuilder(BuilderConstants.OPEN_BRACKET);
// for (int i = 0; i < numbers.length; i++) {
// builder.append(numbers[i]);
// if(i < numbers.length - 1){
// builder.append(BuilderConstants.COMMA_SPACE);
// }
// }
// builder.append(BuilderConstants.CLOSE_BRACKET);
//
// return builder.toString();
// }
//
// }
//
// Path: ugeojson-model/src/main/java/org/ugeojson/model/PositionDto.java
// public class PositionDto implements Serializable {
//
// private static final long serialVersionUID = 1L;
//
// private double[] numbers;
//
// /**
// * This constructor initializes numbers field to hold two double numbers. Do
// * not use this constructor if you need the third elevation parameter.
// */
// public PositionDto() {
// this.numbers = new double[2];
// }
//
// /**
// * Simple coordinate position constructor
// *
// * @param longitude
// * @param latitude
// */
// public PositionDto(double longitude, double latitude) {
// this.numbers = new double[] { longitude, latitude };
// }
//
// /**
// * Use this constructor if you need elevation parameter
// *
// * @param longitude
// * @param latitude
// * @param elevation
// */
// public PositionDto(double longitude, double latitude, double elevation) {
// this.numbers = new double[] { longitude, latitude, elevation };
// }
//
// /**
// * Copy constructor
// *
// * @param position
// */
// public PositionDto(PositionDto position) {
// if (position != null) {
// double[] copyNumbers = position.getNumbers();
// this.numbers = new double[copyNumbers.length];
// for (int i = 0; i < copyNumbers.length; i++) {
// this.numbers[i] = copyNumbers[i];
// }
// }
// }
//
// @Override
// public String toString() {
// if (numbers == null) {
// return "null numbers[]";
// }
// StringBuilder value = new StringBuilder("[");
// for (int i = 0; i < numbers.length; i++) {
// value.append(numbers[i]);
// if (i < numbers.length - 1) {
// value.append(", ");
// }
// }
// value.append("]");
// return value.toString();
// }
//
// public void setLongitude(double longitude) {
// this.numbers[0] = longitude;
// }
//
// public double getLongitude() {
// return numbers[0];
// }
//
// public void setLatitude(double latitude) {
// this.numbers[1] = latitude;
// }
//
// public double getLatitude() {
// return numbers[1];
// }
//
// public void setElevation(double elevation) {
// this.numbers[2] = elevation;
// }
//
// public double getElevation() {
// return numbers[2];
// }
//
// public double[] getNumbers() {
// return numbers;
// }
//
// public void setNumbers(double[] numbers) {
// this.numbers = numbers;
// }
// }
| import static org.hamcrest.CoreMatchers.equalTo;
import static org.junit.Assert.assertThat;
import org.junit.Test;
import org.ugeojson.builder.geometry.PositionBuilder;
import org.ugeojson.model.PositionDto; | package org.ugeojson.builder.geometry;
public class PositionBuilderShould {
@Test public void
build_two_dimension_position(){ | // Path: ugeojson-builder/src/main/java/org/ugeojson/builder/geometry/PositionBuilder.java
// public class PositionBuilder {
//
// private static final int MINIMUM_POSITION_DIMENSION = 2;
//
// private static final PositionBuilder INSTANCE = new PositionBuilder();
//
//
// public static PositionBuilder getInstance(){
// return INSTANCE;
// }
//
// private PositionBuilder(){
// }
//
// public String position(PositionDto position) {
// if(position == null || position.getNumbers().length < MINIMUM_POSITION_DIMENSION){
// throw new InvalidPositionDtoException(position);
// }
//
// double[] numbers = position.getNumbers();
// StringBuilder builder = new StringBuilder(BuilderConstants.OPEN_BRACKET);
// for (int i = 0; i < numbers.length; i++) {
// builder.append(numbers[i]);
// if(i < numbers.length - 1){
// builder.append(BuilderConstants.COMMA_SPACE);
// }
// }
// builder.append(BuilderConstants.CLOSE_BRACKET);
//
// return builder.toString();
// }
//
// }
//
// Path: ugeojson-model/src/main/java/org/ugeojson/model/PositionDto.java
// public class PositionDto implements Serializable {
//
// private static final long serialVersionUID = 1L;
//
// private double[] numbers;
//
// /**
// * This constructor initializes numbers field to hold two double numbers. Do
// * not use this constructor if you need the third elevation parameter.
// */
// public PositionDto() {
// this.numbers = new double[2];
// }
//
// /**
// * Simple coordinate position constructor
// *
// * @param longitude
// * @param latitude
// */
// public PositionDto(double longitude, double latitude) {
// this.numbers = new double[] { longitude, latitude };
// }
//
// /**
// * Use this constructor if you need elevation parameter
// *
// * @param longitude
// * @param latitude
// * @param elevation
// */
// public PositionDto(double longitude, double latitude, double elevation) {
// this.numbers = new double[] { longitude, latitude, elevation };
// }
//
// /**
// * Copy constructor
// *
// * @param position
// */
// public PositionDto(PositionDto position) {
// if (position != null) {
// double[] copyNumbers = position.getNumbers();
// this.numbers = new double[copyNumbers.length];
// for (int i = 0; i < copyNumbers.length; i++) {
// this.numbers[i] = copyNumbers[i];
// }
// }
// }
//
// @Override
// public String toString() {
// if (numbers == null) {
// return "null numbers[]";
// }
// StringBuilder value = new StringBuilder("[");
// for (int i = 0; i < numbers.length; i++) {
// value.append(numbers[i]);
// if (i < numbers.length - 1) {
// value.append(", ");
// }
// }
// value.append("]");
// return value.toString();
// }
//
// public void setLongitude(double longitude) {
// this.numbers[0] = longitude;
// }
//
// public double getLongitude() {
// return numbers[0];
// }
//
// public void setLatitude(double latitude) {
// this.numbers[1] = latitude;
// }
//
// public double getLatitude() {
// return numbers[1];
// }
//
// public void setElevation(double elevation) {
// this.numbers[2] = elevation;
// }
//
// public double getElevation() {
// return numbers[2];
// }
//
// public double[] getNumbers() {
// return numbers;
// }
//
// public void setNumbers(double[] numbers) {
// this.numbers = numbers;
// }
// }
// Path: ugeojson-builder/src/test/java/org/ugeojson/builder/geometry/PositionBuilderShould.java
import static org.hamcrest.CoreMatchers.equalTo;
import static org.junit.Assert.assertThat;
import org.junit.Test;
import org.ugeojson.builder.geometry.PositionBuilder;
import org.ugeojson.model.PositionDto;
package org.ugeojson.builder.geometry;
public class PositionBuilderShould {
@Test public void
build_two_dimension_position(){ | PositionDto position = new PositionDto(14.147, 36.985); |
mokszr/ultimate-geojson | ugeojson-builder/src/test/java/org/ugeojson/builder/geometry/PositionBuilderShould.java | // Path: ugeojson-builder/src/main/java/org/ugeojson/builder/geometry/PositionBuilder.java
// public class PositionBuilder {
//
// private static final int MINIMUM_POSITION_DIMENSION = 2;
//
// private static final PositionBuilder INSTANCE = new PositionBuilder();
//
//
// public static PositionBuilder getInstance(){
// return INSTANCE;
// }
//
// private PositionBuilder(){
// }
//
// public String position(PositionDto position) {
// if(position == null || position.getNumbers().length < MINIMUM_POSITION_DIMENSION){
// throw new InvalidPositionDtoException(position);
// }
//
// double[] numbers = position.getNumbers();
// StringBuilder builder = new StringBuilder(BuilderConstants.OPEN_BRACKET);
// for (int i = 0; i < numbers.length; i++) {
// builder.append(numbers[i]);
// if(i < numbers.length - 1){
// builder.append(BuilderConstants.COMMA_SPACE);
// }
// }
// builder.append(BuilderConstants.CLOSE_BRACKET);
//
// return builder.toString();
// }
//
// }
//
// Path: ugeojson-model/src/main/java/org/ugeojson/model/PositionDto.java
// public class PositionDto implements Serializable {
//
// private static final long serialVersionUID = 1L;
//
// private double[] numbers;
//
// /**
// * This constructor initializes numbers field to hold two double numbers. Do
// * not use this constructor if you need the third elevation parameter.
// */
// public PositionDto() {
// this.numbers = new double[2];
// }
//
// /**
// * Simple coordinate position constructor
// *
// * @param longitude
// * @param latitude
// */
// public PositionDto(double longitude, double latitude) {
// this.numbers = new double[] { longitude, latitude };
// }
//
// /**
// * Use this constructor if you need elevation parameter
// *
// * @param longitude
// * @param latitude
// * @param elevation
// */
// public PositionDto(double longitude, double latitude, double elevation) {
// this.numbers = new double[] { longitude, latitude, elevation };
// }
//
// /**
// * Copy constructor
// *
// * @param position
// */
// public PositionDto(PositionDto position) {
// if (position != null) {
// double[] copyNumbers = position.getNumbers();
// this.numbers = new double[copyNumbers.length];
// for (int i = 0; i < copyNumbers.length; i++) {
// this.numbers[i] = copyNumbers[i];
// }
// }
// }
//
// @Override
// public String toString() {
// if (numbers == null) {
// return "null numbers[]";
// }
// StringBuilder value = new StringBuilder("[");
// for (int i = 0; i < numbers.length; i++) {
// value.append(numbers[i]);
// if (i < numbers.length - 1) {
// value.append(", ");
// }
// }
// value.append("]");
// return value.toString();
// }
//
// public void setLongitude(double longitude) {
// this.numbers[0] = longitude;
// }
//
// public double getLongitude() {
// return numbers[0];
// }
//
// public void setLatitude(double latitude) {
// this.numbers[1] = latitude;
// }
//
// public double getLatitude() {
// return numbers[1];
// }
//
// public void setElevation(double elevation) {
// this.numbers[2] = elevation;
// }
//
// public double getElevation() {
// return numbers[2];
// }
//
// public double[] getNumbers() {
// return numbers;
// }
//
// public void setNumbers(double[] numbers) {
// this.numbers = numbers;
// }
// }
| import static org.hamcrest.CoreMatchers.equalTo;
import static org.junit.Assert.assertThat;
import org.junit.Test;
import org.ugeojson.builder.geometry.PositionBuilder;
import org.ugeojson.model.PositionDto; | package org.ugeojson.builder.geometry;
public class PositionBuilderShould {
@Test public void
build_two_dimension_position(){
PositionDto position = new PositionDto(14.147, 36.985); | // Path: ugeojson-builder/src/main/java/org/ugeojson/builder/geometry/PositionBuilder.java
// public class PositionBuilder {
//
// private static final int MINIMUM_POSITION_DIMENSION = 2;
//
// private static final PositionBuilder INSTANCE = new PositionBuilder();
//
//
// public static PositionBuilder getInstance(){
// return INSTANCE;
// }
//
// private PositionBuilder(){
// }
//
// public String position(PositionDto position) {
// if(position == null || position.getNumbers().length < MINIMUM_POSITION_DIMENSION){
// throw new InvalidPositionDtoException(position);
// }
//
// double[] numbers = position.getNumbers();
// StringBuilder builder = new StringBuilder(BuilderConstants.OPEN_BRACKET);
// for (int i = 0; i < numbers.length; i++) {
// builder.append(numbers[i]);
// if(i < numbers.length - 1){
// builder.append(BuilderConstants.COMMA_SPACE);
// }
// }
// builder.append(BuilderConstants.CLOSE_BRACKET);
//
// return builder.toString();
// }
//
// }
//
// Path: ugeojson-model/src/main/java/org/ugeojson/model/PositionDto.java
// public class PositionDto implements Serializable {
//
// private static final long serialVersionUID = 1L;
//
// private double[] numbers;
//
// /**
// * This constructor initializes numbers field to hold two double numbers. Do
// * not use this constructor if you need the third elevation parameter.
// */
// public PositionDto() {
// this.numbers = new double[2];
// }
//
// /**
// * Simple coordinate position constructor
// *
// * @param longitude
// * @param latitude
// */
// public PositionDto(double longitude, double latitude) {
// this.numbers = new double[] { longitude, latitude };
// }
//
// /**
// * Use this constructor if you need elevation parameter
// *
// * @param longitude
// * @param latitude
// * @param elevation
// */
// public PositionDto(double longitude, double latitude, double elevation) {
// this.numbers = new double[] { longitude, latitude, elevation };
// }
//
// /**
// * Copy constructor
// *
// * @param position
// */
// public PositionDto(PositionDto position) {
// if (position != null) {
// double[] copyNumbers = position.getNumbers();
// this.numbers = new double[copyNumbers.length];
// for (int i = 0; i < copyNumbers.length; i++) {
// this.numbers[i] = copyNumbers[i];
// }
// }
// }
//
// @Override
// public String toString() {
// if (numbers == null) {
// return "null numbers[]";
// }
// StringBuilder value = new StringBuilder("[");
// for (int i = 0; i < numbers.length; i++) {
// value.append(numbers[i]);
// if (i < numbers.length - 1) {
// value.append(", ");
// }
// }
// value.append("]");
// return value.toString();
// }
//
// public void setLongitude(double longitude) {
// this.numbers[0] = longitude;
// }
//
// public double getLongitude() {
// return numbers[0];
// }
//
// public void setLatitude(double latitude) {
// this.numbers[1] = latitude;
// }
//
// public double getLatitude() {
// return numbers[1];
// }
//
// public void setElevation(double elevation) {
// this.numbers[2] = elevation;
// }
//
// public double getElevation() {
// return numbers[2];
// }
//
// public double[] getNumbers() {
// return numbers;
// }
//
// public void setNumbers(double[] numbers) {
// this.numbers = numbers;
// }
// }
// Path: ugeojson-builder/src/test/java/org/ugeojson/builder/geometry/PositionBuilderShould.java
import static org.hamcrest.CoreMatchers.equalTo;
import static org.junit.Assert.assertThat;
import org.junit.Test;
import org.ugeojson.builder.geometry.PositionBuilder;
import org.ugeojson.model.PositionDto;
package org.ugeojson.builder.geometry;
public class PositionBuilderShould {
@Test public void
build_two_dimension_position(){
PositionDto position = new PositionDto(14.147, 36.985); | String positionGeojson = PositionBuilder.getInstance().position(position); |
mokszr/ultimate-geojson | ugeojson-builder/src/test/java/org/ugeojson/builder/geometry/MultiPointBuilderShould.java | // Path: ugeojson-builder/src/main/java/org/ugeojson/builder/geometry/MultiPointBuilder.java
// public class MultiPointBuilder extends GeometryBuilder<MultiPointDto> {
//
// private static final MultiPointBuilder INSTANCE = new MultiPointBuilder();
//
// public static MultiPointBuilder getInstance() {
// return INSTANCE;
// }
//
// private MultiPointBuilder() {
// }
//
// @Override
// public String toGeoJSON(MultiPointDto multiPoint) {
// if (multiPoint == null || multiPoint.getPositions() == null || multiPoint.getPositions().isEmpty()) {
// return BuilderConstants.NULL_VALUE;
// }
//
// StringBuilder builder = initializeBuilder();
// buildTypePart(builder, GeoJSONObjectTypeEnum.MultiPoint);
// builder.append(BuilderConstants.COORDINATES_SPACE);
//
// builder.append(BuilderConstants.OPEN_BRACKET);
// builder.append(BuilderConstants.NEWLINE);
//
// List<PositionDto> positions = multiPoint.getPositions();
// for (int i = 0; i < positions.size(); i++) {
// PositionDto position = positions.get(i);
// builder.append(PositionBuilder.getInstance().position(position));
// if (i < positions.size() - 1) {
// builder.append(BuilderConstants.COMMA_NEWLINE);
// } else {
// builder.append(BuilderConstants.NEWLINE);
// }
// }
//
// builder.append(BuilderConstants.CLOSE_BRACKET);
//
// buildBbox(builder, multiPoint.getBbox());
// endBuilder(builder);
// return builder.toString();
// }
//
// }
//
// Path: ugeojson-model/src/main/java/org/ugeojson/model/PositionDto.java
// public class PositionDto implements Serializable {
//
// private static final long serialVersionUID = 1L;
//
// private double[] numbers;
//
// /**
// * This constructor initializes numbers field to hold two double numbers. Do
// * not use this constructor if you need the third elevation parameter.
// */
// public PositionDto() {
// this.numbers = new double[2];
// }
//
// /**
// * Simple coordinate position constructor
// *
// * @param longitude
// * @param latitude
// */
// public PositionDto(double longitude, double latitude) {
// this.numbers = new double[] { longitude, latitude };
// }
//
// /**
// * Use this constructor if you need elevation parameter
// *
// * @param longitude
// * @param latitude
// * @param elevation
// */
// public PositionDto(double longitude, double latitude, double elevation) {
// this.numbers = new double[] { longitude, latitude, elevation };
// }
//
// /**
// * Copy constructor
// *
// * @param position
// */
// public PositionDto(PositionDto position) {
// if (position != null) {
// double[] copyNumbers = position.getNumbers();
// this.numbers = new double[copyNumbers.length];
// for (int i = 0; i < copyNumbers.length; i++) {
// this.numbers[i] = copyNumbers[i];
// }
// }
// }
//
// @Override
// public String toString() {
// if (numbers == null) {
// return "null numbers[]";
// }
// StringBuilder value = new StringBuilder("[");
// for (int i = 0; i < numbers.length; i++) {
// value.append(numbers[i]);
// if (i < numbers.length - 1) {
// value.append(", ");
// }
// }
// value.append("]");
// return value.toString();
// }
//
// public void setLongitude(double longitude) {
// this.numbers[0] = longitude;
// }
//
// public double getLongitude() {
// return numbers[0];
// }
//
// public void setLatitude(double latitude) {
// this.numbers[1] = latitude;
// }
//
// public double getLatitude() {
// return numbers[1];
// }
//
// public void setElevation(double elevation) {
// this.numbers[2] = elevation;
// }
//
// public double getElevation() {
// return numbers[2];
// }
//
// public double[] getNumbers() {
// return numbers;
// }
//
// public void setNumbers(double[] numbers) {
// this.numbers = numbers;
// }
// }
//
// Path: ugeojson-model/src/main/java/org/ugeojson/model/geometry/MultiPointDto.java
// public class MultiPointDto extends GeometryDto {
//
// private static final long serialVersionUID = 1L;
//
// private List<PositionDto> positions;
//
// public List<PositionDto> getPositions() {
// return positions;
// }
//
// public void setPositions(List<PositionDto> positions) {
// this.positions = positions;
// }
//
// @Override
// public GeoJSONObjectTypeEnum getGeoJSONObjectType() {
// return GeoJSONObjectTypeEnum.MultiPoint;
// }
// }
| import static org.hamcrest.CoreMatchers.equalTo;
import static org.junit.Assert.assertThat;
import java.util.ArrayList;
import java.util.List;
import org.junit.Test;
import org.ugeojson.builder.geometry.MultiPointBuilder;
import org.ugeojson.model.PositionDto;
import org.ugeojson.model.geometry.MultiPointDto; | package org.ugeojson.builder.geometry;
public class MultiPointBuilderShould {
@Test
public void build_multipoint() { | // Path: ugeojson-builder/src/main/java/org/ugeojson/builder/geometry/MultiPointBuilder.java
// public class MultiPointBuilder extends GeometryBuilder<MultiPointDto> {
//
// private static final MultiPointBuilder INSTANCE = new MultiPointBuilder();
//
// public static MultiPointBuilder getInstance() {
// return INSTANCE;
// }
//
// private MultiPointBuilder() {
// }
//
// @Override
// public String toGeoJSON(MultiPointDto multiPoint) {
// if (multiPoint == null || multiPoint.getPositions() == null || multiPoint.getPositions().isEmpty()) {
// return BuilderConstants.NULL_VALUE;
// }
//
// StringBuilder builder = initializeBuilder();
// buildTypePart(builder, GeoJSONObjectTypeEnum.MultiPoint);
// builder.append(BuilderConstants.COORDINATES_SPACE);
//
// builder.append(BuilderConstants.OPEN_BRACKET);
// builder.append(BuilderConstants.NEWLINE);
//
// List<PositionDto> positions = multiPoint.getPositions();
// for (int i = 0; i < positions.size(); i++) {
// PositionDto position = positions.get(i);
// builder.append(PositionBuilder.getInstance().position(position));
// if (i < positions.size() - 1) {
// builder.append(BuilderConstants.COMMA_NEWLINE);
// } else {
// builder.append(BuilderConstants.NEWLINE);
// }
// }
//
// builder.append(BuilderConstants.CLOSE_BRACKET);
//
// buildBbox(builder, multiPoint.getBbox());
// endBuilder(builder);
// return builder.toString();
// }
//
// }
//
// Path: ugeojson-model/src/main/java/org/ugeojson/model/PositionDto.java
// public class PositionDto implements Serializable {
//
// private static final long serialVersionUID = 1L;
//
// private double[] numbers;
//
// /**
// * This constructor initializes numbers field to hold two double numbers. Do
// * not use this constructor if you need the third elevation parameter.
// */
// public PositionDto() {
// this.numbers = new double[2];
// }
//
// /**
// * Simple coordinate position constructor
// *
// * @param longitude
// * @param latitude
// */
// public PositionDto(double longitude, double latitude) {
// this.numbers = new double[] { longitude, latitude };
// }
//
// /**
// * Use this constructor if you need elevation parameter
// *
// * @param longitude
// * @param latitude
// * @param elevation
// */
// public PositionDto(double longitude, double latitude, double elevation) {
// this.numbers = new double[] { longitude, latitude, elevation };
// }
//
// /**
// * Copy constructor
// *
// * @param position
// */
// public PositionDto(PositionDto position) {
// if (position != null) {
// double[] copyNumbers = position.getNumbers();
// this.numbers = new double[copyNumbers.length];
// for (int i = 0; i < copyNumbers.length; i++) {
// this.numbers[i] = copyNumbers[i];
// }
// }
// }
//
// @Override
// public String toString() {
// if (numbers == null) {
// return "null numbers[]";
// }
// StringBuilder value = new StringBuilder("[");
// for (int i = 0; i < numbers.length; i++) {
// value.append(numbers[i]);
// if (i < numbers.length - 1) {
// value.append(", ");
// }
// }
// value.append("]");
// return value.toString();
// }
//
// public void setLongitude(double longitude) {
// this.numbers[0] = longitude;
// }
//
// public double getLongitude() {
// return numbers[0];
// }
//
// public void setLatitude(double latitude) {
// this.numbers[1] = latitude;
// }
//
// public double getLatitude() {
// return numbers[1];
// }
//
// public void setElevation(double elevation) {
// this.numbers[2] = elevation;
// }
//
// public double getElevation() {
// return numbers[2];
// }
//
// public double[] getNumbers() {
// return numbers;
// }
//
// public void setNumbers(double[] numbers) {
// this.numbers = numbers;
// }
// }
//
// Path: ugeojson-model/src/main/java/org/ugeojson/model/geometry/MultiPointDto.java
// public class MultiPointDto extends GeometryDto {
//
// private static final long serialVersionUID = 1L;
//
// private List<PositionDto> positions;
//
// public List<PositionDto> getPositions() {
// return positions;
// }
//
// public void setPositions(List<PositionDto> positions) {
// this.positions = positions;
// }
//
// @Override
// public GeoJSONObjectTypeEnum getGeoJSONObjectType() {
// return GeoJSONObjectTypeEnum.MultiPoint;
// }
// }
// Path: ugeojson-builder/src/test/java/org/ugeojson/builder/geometry/MultiPointBuilderShould.java
import static org.hamcrest.CoreMatchers.equalTo;
import static org.junit.Assert.assertThat;
import java.util.ArrayList;
import java.util.List;
import org.junit.Test;
import org.ugeojson.builder.geometry.MultiPointBuilder;
import org.ugeojson.model.PositionDto;
import org.ugeojson.model.geometry.MultiPointDto;
package org.ugeojson.builder.geometry;
public class MultiPointBuilderShould {
@Test
public void build_multipoint() { | MultiPointDto multiPoint = new MultiPointDto(); |
mokszr/ultimate-geojson | ugeojson-builder/src/test/java/org/ugeojson/builder/geometry/MultiPointBuilderShould.java | // Path: ugeojson-builder/src/main/java/org/ugeojson/builder/geometry/MultiPointBuilder.java
// public class MultiPointBuilder extends GeometryBuilder<MultiPointDto> {
//
// private static final MultiPointBuilder INSTANCE = new MultiPointBuilder();
//
// public static MultiPointBuilder getInstance() {
// return INSTANCE;
// }
//
// private MultiPointBuilder() {
// }
//
// @Override
// public String toGeoJSON(MultiPointDto multiPoint) {
// if (multiPoint == null || multiPoint.getPositions() == null || multiPoint.getPositions().isEmpty()) {
// return BuilderConstants.NULL_VALUE;
// }
//
// StringBuilder builder = initializeBuilder();
// buildTypePart(builder, GeoJSONObjectTypeEnum.MultiPoint);
// builder.append(BuilderConstants.COORDINATES_SPACE);
//
// builder.append(BuilderConstants.OPEN_BRACKET);
// builder.append(BuilderConstants.NEWLINE);
//
// List<PositionDto> positions = multiPoint.getPositions();
// for (int i = 0; i < positions.size(); i++) {
// PositionDto position = positions.get(i);
// builder.append(PositionBuilder.getInstance().position(position));
// if (i < positions.size() - 1) {
// builder.append(BuilderConstants.COMMA_NEWLINE);
// } else {
// builder.append(BuilderConstants.NEWLINE);
// }
// }
//
// builder.append(BuilderConstants.CLOSE_BRACKET);
//
// buildBbox(builder, multiPoint.getBbox());
// endBuilder(builder);
// return builder.toString();
// }
//
// }
//
// Path: ugeojson-model/src/main/java/org/ugeojson/model/PositionDto.java
// public class PositionDto implements Serializable {
//
// private static final long serialVersionUID = 1L;
//
// private double[] numbers;
//
// /**
// * This constructor initializes numbers field to hold two double numbers. Do
// * not use this constructor if you need the third elevation parameter.
// */
// public PositionDto() {
// this.numbers = new double[2];
// }
//
// /**
// * Simple coordinate position constructor
// *
// * @param longitude
// * @param latitude
// */
// public PositionDto(double longitude, double latitude) {
// this.numbers = new double[] { longitude, latitude };
// }
//
// /**
// * Use this constructor if you need elevation parameter
// *
// * @param longitude
// * @param latitude
// * @param elevation
// */
// public PositionDto(double longitude, double latitude, double elevation) {
// this.numbers = new double[] { longitude, latitude, elevation };
// }
//
// /**
// * Copy constructor
// *
// * @param position
// */
// public PositionDto(PositionDto position) {
// if (position != null) {
// double[] copyNumbers = position.getNumbers();
// this.numbers = new double[copyNumbers.length];
// for (int i = 0; i < copyNumbers.length; i++) {
// this.numbers[i] = copyNumbers[i];
// }
// }
// }
//
// @Override
// public String toString() {
// if (numbers == null) {
// return "null numbers[]";
// }
// StringBuilder value = new StringBuilder("[");
// for (int i = 0; i < numbers.length; i++) {
// value.append(numbers[i]);
// if (i < numbers.length - 1) {
// value.append(", ");
// }
// }
// value.append("]");
// return value.toString();
// }
//
// public void setLongitude(double longitude) {
// this.numbers[0] = longitude;
// }
//
// public double getLongitude() {
// return numbers[0];
// }
//
// public void setLatitude(double latitude) {
// this.numbers[1] = latitude;
// }
//
// public double getLatitude() {
// return numbers[1];
// }
//
// public void setElevation(double elevation) {
// this.numbers[2] = elevation;
// }
//
// public double getElevation() {
// return numbers[2];
// }
//
// public double[] getNumbers() {
// return numbers;
// }
//
// public void setNumbers(double[] numbers) {
// this.numbers = numbers;
// }
// }
//
// Path: ugeojson-model/src/main/java/org/ugeojson/model/geometry/MultiPointDto.java
// public class MultiPointDto extends GeometryDto {
//
// private static final long serialVersionUID = 1L;
//
// private List<PositionDto> positions;
//
// public List<PositionDto> getPositions() {
// return positions;
// }
//
// public void setPositions(List<PositionDto> positions) {
// this.positions = positions;
// }
//
// @Override
// public GeoJSONObjectTypeEnum getGeoJSONObjectType() {
// return GeoJSONObjectTypeEnum.MultiPoint;
// }
// }
| import static org.hamcrest.CoreMatchers.equalTo;
import static org.junit.Assert.assertThat;
import java.util.ArrayList;
import java.util.List;
import org.junit.Test;
import org.ugeojson.builder.geometry.MultiPointBuilder;
import org.ugeojson.model.PositionDto;
import org.ugeojson.model.geometry.MultiPointDto; | package org.ugeojson.builder.geometry;
public class MultiPointBuilderShould {
@Test
public void build_multipoint() {
MultiPointDto multiPoint = new MultiPointDto(); | // Path: ugeojson-builder/src/main/java/org/ugeojson/builder/geometry/MultiPointBuilder.java
// public class MultiPointBuilder extends GeometryBuilder<MultiPointDto> {
//
// private static final MultiPointBuilder INSTANCE = new MultiPointBuilder();
//
// public static MultiPointBuilder getInstance() {
// return INSTANCE;
// }
//
// private MultiPointBuilder() {
// }
//
// @Override
// public String toGeoJSON(MultiPointDto multiPoint) {
// if (multiPoint == null || multiPoint.getPositions() == null || multiPoint.getPositions().isEmpty()) {
// return BuilderConstants.NULL_VALUE;
// }
//
// StringBuilder builder = initializeBuilder();
// buildTypePart(builder, GeoJSONObjectTypeEnum.MultiPoint);
// builder.append(BuilderConstants.COORDINATES_SPACE);
//
// builder.append(BuilderConstants.OPEN_BRACKET);
// builder.append(BuilderConstants.NEWLINE);
//
// List<PositionDto> positions = multiPoint.getPositions();
// for (int i = 0; i < positions.size(); i++) {
// PositionDto position = positions.get(i);
// builder.append(PositionBuilder.getInstance().position(position));
// if (i < positions.size() - 1) {
// builder.append(BuilderConstants.COMMA_NEWLINE);
// } else {
// builder.append(BuilderConstants.NEWLINE);
// }
// }
//
// builder.append(BuilderConstants.CLOSE_BRACKET);
//
// buildBbox(builder, multiPoint.getBbox());
// endBuilder(builder);
// return builder.toString();
// }
//
// }
//
// Path: ugeojson-model/src/main/java/org/ugeojson/model/PositionDto.java
// public class PositionDto implements Serializable {
//
// private static final long serialVersionUID = 1L;
//
// private double[] numbers;
//
// /**
// * This constructor initializes numbers field to hold two double numbers. Do
// * not use this constructor if you need the third elevation parameter.
// */
// public PositionDto() {
// this.numbers = new double[2];
// }
//
// /**
// * Simple coordinate position constructor
// *
// * @param longitude
// * @param latitude
// */
// public PositionDto(double longitude, double latitude) {
// this.numbers = new double[] { longitude, latitude };
// }
//
// /**
// * Use this constructor if you need elevation parameter
// *
// * @param longitude
// * @param latitude
// * @param elevation
// */
// public PositionDto(double longitude, double latitude, double elevation) {
// this.numbers = new double[] { longitude, latitude, elevation };
// }
//
// /**
// * Copy constructor
// *
// * @param position
// */
// public PositionDto(PositionDto position) {
// if (position != null) {
// double[] copyNumbers = position.getNumbers();
// this.numbers = new double[copyNumbers.length];
// for (int i = 0; i < copyNumbers.length; i++) {
// this.numbers[i] = copyNumbers[i];
// }
// }
// }
//
// @Override
// public String toString() {
// if (numbers == null) {
// return "null numbers[]";
// }
// StringBuilder value = new StringBuilder("[");
// for (int i = 0; i < numbers.length; i++) {
// value.append(numbers[i]);
// if (i < numbers.length - 1) {
// value.append(", ");
// }
// }
// value.append("]");
// return value.toString();
// }
//
// public void setLongitude(double longitude) {
// this.numbers[0] = longitude;
// }
//
// public double getLongitude() {
// return numbers[0];
// }
//
// public void setLatitude(double latitude) {
// this.numbers[1] = latitude;
// }
//
// public double getLatitude() {
// return numbers[1];
// }
//
// public void setElevation(double elevation) {
// this.numbers[2] = elevation;
// }
//
// public double getElevation() {
// return numbers[2];
// }
//
// public double[] getNumbers() {
// return numbers;
// }
//
// public void setNumbers(double[] numbers) {
// this.numbers = numbers;
// }
// }
//
// Path: ugeojson-model/src/main/java/org/ugeojson/model/geometry/MultiPointDto.java
// public class MultiPointDto extends GeometryDto {
//
// private static final long serialVersionUID = 1L;
//
// private List<PositionDto> positions;
//
// public List<PositionDto> getPositions() {
// return positions;
// }
//
// public void setPositions(List<PositionDto> positions) {
// this.positions = positions;
// }
//
// @Override
// public GeoJSONObjectTypeEnum getGeoJSONObjectType() {
// return GeoJSONObjectTypeEnum.MultiPoint;
// }
// }
// Path: ugeojson-builder/src/test/java/org/ugeojson/builder/geometry/MultiPointBuilderShould.java
import static org.hamcrest.CoreMatchers.equalTo;
import static org.junit.Assert.assertThat;
import java.util.ArrayList;
import java.util.List;
import org.junit.Test;
import org.ugeojson.builder.geometry.MultiPointBuilder;
import org.ugeojson.model.PositionDto;
import org.ugeojson.model.geometry.MultiPointDto;
package org.ugeojson.builder.geometry;
public class MultiPointBuilderShould {
@Test
public void build_multipoint() {
MultiPointDto multiPoint = new MultiPointDto(); | List<PositionDto> positions = new ArrayList<>(); |
mokszr/ultimate-geojson | ugeojson-builder/src/test/java/org/ugeojson/builder/geometry/MultiPointBuilderShould.java | // Path: ugeojson-builder/src/main/java/org/ugeojson/builder/geometry/MultiPointBuilder.java
// public class MultiPointBuilder extends GeometryBuilder<MultiPointDto> {
//
// private static final MultiPointBuilder INSTANCE = new MultiPointBuilder();
//
// public static MultiPointBuilder getInstance() {
// return INSTANCE;
// }
//
// private MultiPointBuilder() {
// }
//
// @Override
// public String toGeoJSON(MultiPointDto multiPoint) {
// if (multiPoint == null || multiPoint.getPositions() == null || multiPoint.getPositions().isEmpty()) {
// return BuilderConstants.NULL_VALUE;
// }
//
// StringBuilder builder = initializeBuilder();
// buildTypePart(builder, GeoJSONObjectTypeEnum.MultiPoint);
// builder.append(BuilderConstants.COORDINATES_SPACE);
//
// builder.append(BuilderConstants.OPEN_BRACKET);
// builder.append(BuilderConstants.NEWLINE);
//
// List<PositionDto> positions = multiPoint.getPositions();
// for (int i = 0; i < positions.size(); i++) {
// PositionDto position = positions.get(i);
// builder.append(PositionBuilder.getInstance().position(position));
// if (i < positions.size() - 1) {
// builder.append(BuilderConstants.COMMA_NEWLINE);
// } else {
// builder.append(BuilderConstants.NEWLINE);
// }
// }
//
// builder.append(BuilderConstants.CLOSE_BRACKET);
//
// buildBbox(builder, multiPoint.getBbox());
// endBuilder(builder);
// return builder.toString();
// }
//
// }
//
// Path: ugeojson-model/src/main/java/org/ugeojson/model/PositionDto.java
// public class PositionDto implements Serializable {
//
// private static final long serialVersionUID = 1L;
//
// private double[] numbers;
//
// /**
// * This constructor initializes numbers field to hold two double numbers. Do
// * not use this constructor if you need the third elevation parameter.
// */
// public PositionDto() {
// this.numbers = new double[2];
// }
//
// /**
// * Simple coordinate position constructor
// *
// * @param longitude
// * @param latitude
// */
// public PositionDto(double longitude, double latitude) {
// this.numbers = new double[] { longitude, latitude };
// }
//
// /**
// * Use this constructor if you need elevation parameter
// *
// * @param longitude
// * @param latitude
// * @param elevation
// */
// public PositionDto(double longitude, double latitude, double elevation) {
// this.numbers = new double[] { longitude, latitude, elevation };
// }
//
// /**
// * Copy constructor
// *
// * @param position
// */
// public PositionDto(PositionDto position) {
// if (position != null) {
// double[] copyNumbers = position.getNumbers();
// this.numbers = new double[copyNumbers.length];
// for (int i = 0; i < copyNumbers.length; i++) {
// this.numbers[i] = copyNumbers[i];
// }
// }
// }
//
// @Override
// public String toString() {
// if (numbers == null) {
// return "null numbers[]";
// }
// StringBuilder value = new StringBuilder("[");
// for (int i = 0; i < numbers.length; i++) {
// value.append(numbers[i]);
// if (i < numbers.length - 1) {
// value.append(", ");
// }
// }
// value.append("]");
// return value.toString();
// }
//
// public void setLongitude(double longitude) {
// this.numbers[0] = longitude;
// }
//
// public double getLongitude() {
// return numbers[0];
// }
//
// public void setLatitude(double latitude) {
// this.numbers[1] = latitude;
// }
//
// public double getLatitude() {
// return numbers[1];
// }
//
// public void setElevation(double elevation) {
// this.numbers[2] = elevation;
// }
//
// public double getElevation() {
// return numbers[2];
// }
//
// public double[] getNumbers() {
// return numbers;
// }
//
// public void setNumbers(double[] numbers) {
// this.numbers = numbers;
// }
// }
//
// Path: ugeojson-model/src/main/java/org/ugeojson/model/geometry/MultiPointDto.java
// public class MultiPointDto extends GeometryDto {
//
// private static final long serialVersionUID = 1L;
//
// private List<PositionDto> positions;
//
// public List<PositionDto> getPositions() {
// return positions;
// }
//
// public void setPositions(List<PositionDto> positions) {
// this.positions = positions;
// }
//
// @Override
// public GeoJSONObjectTypeEnum getGeoJSONObjectType() {
// return GeoJSONObjectTypeEnum.MultiPoint;
// }
// }
| import static org.hamcrest.CoreMatchers.equalTo;
import static org.junit.Assert.assertThat;
import java.util.ArrayList;
import java.util.List;
import org.junit.Test;
import org.ugeojson.builder.geometry.MultiPointBuilder;
import org.ugeojson.model.PositionDto;
import org.ugeojson.model.geometry.MultiPointDto; | package org.ugeojson.builder.geometry;
public class MultiPointBuilderShould {
@Test
public void build_multipoint() {
MultiPointDto multiPoint = new MultiPointDto();
List<PositionDto> positions = new ArrayList<>();
positions.add(new PositionDto(32.123, 24.587));
positions.add(new PositionDto(36.1478, 29.3645));
multiPoint.setPositions(positions);
| // Path: ugeojson-builder/src/main/java/org/ugeojson/builder/geometry/MultiPointBuilder.java
// public class MultiPointBuilder extends GeometryBuilder<MultiPointDto> {
//
// private static final MultiPointBuilder INSTANCE = new MultiPointBuilder();
//
// public static MultiPointBuilder getInstance() {
// return INSTANCE;
// }
//
// private MultiPointBuilder() {
// }
//
// @Override
// public String toGeoJSON(MultiPointDto multiPoint) {
// if (multiPoint == null || multiPoint.getPositions() == null || multiPoint.getPositions().isEmpty()) {
// return BuilderConstants.NULL_VALUE;
// }
//
// StringBuilder builder = initializeBuilder();
// buildTypePart(builder, GeoJSONObjectTypeEnum.MultiPoint);
// builder.append(BuilderConstants.COORDINATES_SPACE);
//
// builder.append(BuilderConstants.OPEN_BRACKET);
// builder.append(BuilderConstants.NEWLINE);
//
// List<PositionDto> positions = multiPoint.getPositions();
// for (int i = 0; i < positions.size(); i++) {
// PositionDto position = positions.get(i);
// builder.append(PositionBuilder.getInstance().position(position));
// if (i < positions.size() - 1) {
// builder.append(BuilderConstants.COMMA_NEWLINE);
// } else {
// builder.append(BuilderConstants.NEWLINE);
// }
// }
//
// builder.append(BuilderConstants.CLOSE_BRACKET);
//
// buildBbox(builder, multiPoint.getBbox());
// endBuilder(builder);
// return builder.toString();
// }
//
// }
//
// Path: ugeojson-model/src/main/java/org/ugeojson/model/PositionDto.java
// public class PositionDto implements Serializable {
//
// private static final long serialVersionUID = 1L;
//
// private double[] numbers;
//
// /**
// * This constructor initializes numbers field to hold two double numbers. Do
// * not use this constructor if you need the third elevation parameter.
// */
// public PositionDto() {
// this.numbers = new double[2];
// }
//
// /**
// * Simple coordinate position constructor
// *
// * @param longitude
// * @param latitude
// */
// public PositionDto(double longitude, double latitude) {
// this.numbers = new double[] { longitude, latitude };
// }
//
// /**
// * Use this constructor if you need elevation parameter
// *
// * @param longitude
// * @param latitude
// * @param elevation
// */
// public PositionDto(double longitude, double latitude, double elevation) {
// this.numbers = new double[] { longitude, latitude, elevation };
// }
//
// /**
// * Copy constructor
// *
// * @param position
// */
// public PositionDto(PositionDto position) {
// if (position != null) {
// double[] copyNumbers = position.getNumbers();
// this.numbers = new double[copyNumbers.length];
// for (int i = 0; i < copyNumbers.length; i++) {
// this.numbers[i] = copyNumbers[i];
// }
// }
// }
//
// @Override
// public String toString() {
// if (numbers == null) {
// return "null numbers[]";
// }
// StringBuilder value = new StringBuilder("[");
// for (int i = 0; i < numbers.length; i++) {
// value.append(numbers[i]);
// if (i < numbers.length - 1) {
// value.append(", ");
// }
// }
// value.append("]");
// return value.toString();
// }
//
// public void setLongitude(double longitude) {
// this.numbers[0] = longitude;
// }
//
// public double getLongitude() {
// return numbers[0];
// }
//
// public void setLatitude(double latitude) {
// this.numbers[1] = latitude;
// }
//
// public double getLatitude() {
// return numbers[1];
// }
//
// public void setElevation(double elevation) {
// this.numbers[2] = elevation;
// }
//
// public double getElevation() {
// return numbers[2];
// }
//
// public double[] getNumbers() {
// return numbers;
// }
//
// public void setNumbers(double[] numbers) {
// this.numbers = numbers;
// }
// }
//
// Path: ugeojson-model/src/main/java/org/ugeojson/model/geometry/MultiPointDto.java
// public class MultiPointDto extends GeometryDto {
//
// private static final long serialVersionUID = 1L;
//
// private List<PositionDto> positions;
//
// public List<PositionDto> getPositions() {
// return positions;
// }
//
// public void setPositions(List<PositionDto> positions) {
// this.positions = positions;
// }
//
// @Override
// public GeoJSONObjectTypeEnum getGeoJSONObjectType() {
// return GeoJSONObjectTypeEnum.MultiPoint;
// }
// }
// Path: ugeojson-builder/src/test/java/org/ugeojson/builder/geometry/MultiPointBuilderShould.java
import static org.hamcrest.CoreMatchers.equalTo;
import static org.junit.Assert.assertThat;
import java.util.ArrayList;
import java.util.List;
import org.junit.Test;
import org.ugeojson.builder.geometry.MultiPointBuilder;
import org.ugeojson.model.PositionDto;
import org.ugeojson.model.geometry.MultiPointDto;
package org.ugeojson.builder.geometry;
public class MultiPointBuilderShould {
@Test
public void build_multipoint() {
MultiPointDto multiPoint = new MultiPointDto();
List<PositionDto> positions = new ArrayList<>();
positions.add(new PositionDto(32.123, 24.587));
positions.add(new PositionDto(36.1478, 29.3645));
multiPoint.setPositions(positions);
| String geometryGeoJSON = MultiPointBuilder.getInstance().toGeoJSON(multiPoint); |
mokszr/ultimate-geojson | ugeojson-model/src/test/java/org/ugeojson/model/PositionDtoShould.java | // Path: ugeojson-model/src/main/java/org/ugeojson/model/PositionDto.java
// public class PositionDto implements Serializable {
//
// private static final long serialVersionUID = 1L;
//
// private double[] numbers;
//
// /**
// * This constructor initializes numbers field to hold two double numbers. Do
// * not use this constructor if you need the third elevation parameter.
// */
// public PositionDto() {
// this.numbers = new double[2];
// }
//
// /**
// * Simple coordinate position constructor
// *
// * @param longitude
// * @param latitude
// */
// public PositionDto(double longitude, double latitude) {
// this.numbers = new double[] { longitude, latitude };
// }
//
// /**
// * Use this constructor if you need elevation parameter
// *
// * @param longitude
// * @param latitude
// * @param elevation
// */
// public PositionDto(double longitude, double latitude, double elevation) {
// this.numbers = new double[] { longitude, latitude, elevation };
// }
//
// /**
// * Copy constructor
// *
// * @param position
// */
// public PositionDto(PositionDto position) {
// if (position != null) {
// double[] copyNumbers = position.getNumbers();
// this.numbers = new double[copyNumbers.length];
// for (int i = 0; i < copyNumbers.length; i++) {
// this.numbers[i] = copyNumbers[i];
// }
// }
// }
//
// @Override
// public String toString() {
// if (numbers == null) {
// return "null numbers[]";
// }
// StringBuilder value = new StringBuilder("[");
// for (int i = 0; i < numbers.length; i++) {
// value.append(numbers[i]);
// if (i < numbers.length - 1) {
// value.append(", ");
// }
// }
// value.append("]");
// return value.toString();
// }
//
// public void setLongitude(double longitude) {
// this.numbers[0] = longitude;
// }
//
// public double getLongitude() {
// return numbers[0];
// }
//
// public void setLatitude(double latitude) {
// this.numbers[1] = latitude;
// }
//
// public double getLatitude() {
// return numbers[1];
// }
//
// public void setElevation(double elevation) {
// this.numbers[2] = elevation;
// }
//
// public double getElevation() {
// return numbers[2];
// }
//
// public double[] getNumbers() {
// return numbers;
// }
//
// public void setNumbers(double[] numbers) {
// this.numbers = numbers;
// }
// }
| import static org.hamcrest.CoreMatchers.equalTo;
import static org.junit.Assert.assertThat;
import org.junit.Test;
import org.ugeojson.model.PositionDto; | package org.ugeojson.model;
public class PositionDtoShould {
@Test public void
copy_position(){ | // Path: ugeojson-model/src/main/java/org/ugeojson/model/PositionDto.java
// public class PositionDto implements Serializable {
//
// private static final long serialVersionUID = 1L;
//
// private double[] numbers;
//
// /**
// * This constructor initializes numbers field to hold two double numbers. Do
// * not use this constructor if you need the third elevation parameter.
// */
// public PositionDto() {
// this.numbers = new double[2];
// }
//
// /**
// * Simple coordinate position constructor
// *
// * @param longitude
// * @param latitude
// */
// public PositionDto(double longitude, double latitude) {
// this.numbers = new double[] { longitude, latitude };
// }
//
// /**
// * Use this constructor if you need elevation parameter
// *
// * @param longitude
// * @param latitude
// * @param elevation
// */
// public PositionDto(double longitude, double latitude, double elevation) {
// this.numbers = new double[] { longitude, latitude, elevation };
// }
//
// /**
// * Copy constructor
// *
// * @param position
// */
// public PositionDto(PositionDto position) {
// if (position != null) {
// double[] copyNumbers = position.getNumbers();
// this.numbers = new double[copyNumbers.length];
// for (int i = 0; i < copyNumbers.length; i++) {
// this.numbers[i] = copyNumbers[i];
// }
// }
// }
//
// @Override
// public String toString() {
// if (numbers == null) {
// return "null numbers[]";
// }
// StringBuilder value = new StringBuilder("[");
// for (int i = 0; i < numbers.length; i++) {
// value.append(numbers[i]);
// if (i < numbers.length - 1) {
// value.append(", ");
// }
// }
// value.append("]");
// return value.toString();
// }
//
// public void setLongitude(double longitude) {
// this.numbers[0] = longitude;
// }
//
// public double getLongitude() {
// return numbers[0];
// }
//
// public void setLatitude(double latitude) {
// this.numbers[1] = latitude;
// }
//
// public double getLatitude() {
// return numbers[1];
// }
//
// public void setElevation(double elevation) {
// this.numbers[2] = elevation;
// }
//
// public double getElevation() {
// return numbers[2];
// }
//
// public double[] getNumbers() {
// return numbers;
// }
//
// public void setNumbers(double[] numbers) {
// this.numbers = numbers;
// }
// }
// Path: ugeojson-model/src/test/java/org/ugeojson/model/PositionDtoShould.java
import static org.hamcrest.CoreMatchers.equalTo;
import static org.junit.Assert.assertThat;
import org.junit.Test;
import org.ugeojson.model.PositionDto;
package org.ugeojson.model;
public class PositionDtoShould {
@Test public void
copy_position(){ | PositionDto position = new PositionDto(14.7,23.8); |
mokszr/ultimate-geojson | ugeojson-parser/src/main/java/org/ugeojson/parser/util/BoundingBoxParser.java | // Path: ugeojson-model/src/main/java/org/ugeojson/model/BoundingBoxDto.java
// public class BoundingBoxDto implements Serializable {
//
// private static final long serialVersionUID = 1L;
//
// private PositionDto southWestCorner;
// private PositionDto northEastCorner;
//
// public PositionDto getSouthWestCorner() {
// return southWestCorner;
// }
//
// public void setSouthWestCorner(PositionDto southWestCorner) {
// this.southWestCorner = southWestCorner;
// }
//
// public PositionDto getNorthEastCorner() {
// return northEastCorner;
// }
//
// public void setNorthEastCorner(PositionDto northEastCorner) {
// this.northEastCorner = northEastCorner;
// }
//
// }
//
// Path: ugeojson-model/src/main/java/org/ugeojson/model/PositionDto.java
// public class PositionDto implements Serializable {
//
// private static final long serialVersionUID = 1L;
//
// private double[] numbers;
//
// /**
// * This constructor initializes numbers field to hold two double numbers. Do
// * not use this constructor if you need the third elevation parameter.
// */
// public PositionDto() {
// this.numbers = new double[2];
// }
//
// /**
// * Simple coordinate position constructor
// *
// * @param longitude
// * @param latitude
// */
// public PositionDto(double longitude, double latitude) {
// this.numbers = new double[] { longitude, latitude };
// }
//
// /**
// * Use this constructor if you need elevation parameter
// *
// * @param longitude
// * @param latitude
// * @param elevation
// */
// public PositionDto(double longitude, double latitude, double elevation) {
// this.numbers = new double[] { longitude, latitude, elevation };
// }
//
// /**
// * Copy constructor
// *
// * @param position
// */
// public PositionDto(PositionDto position) {
// if (position != null) {
// double[] copyNumbers = position.getNumbers();
// this.numbers = new double[copyNumbers.length];
// for (int i = 0; i < copyNumbers.length; i++) {
// this.numbers[i] = copyNumbers[i];
// }
// }
// }
//
// @Override
// public String toString() {
// if (numbers == null) {
// return "null numbers[]";
// }
// StringBuilder value = new StringBuilder("[");
// for (int i = 0; i < numbers.length; i++) {
// value.append(numbers[i]);
// if (i < numbers.length - 1) {
// value.append(", ");
// }
// }
// value.append("]");
// return value.toString();
// }
//
// public void setLongitude(double longitude) {
// this.numbers[0] = longitude;
// }
//
// public double getLongitude() {
// return numbers[0];
// }
//
// public void setLatitude(double latitude) {
// this.numbers[1] = latitude;
// }
//
// public double getLatitude() {
// return numbers[1];
// }
//
// public void setElevation(double elevation) {
// this.numbers[2] = elevation;
// }
//
// public double getElevation() {
// return numbers[2];
// }
//
// public double[] getNumbers() {
// return numbers;
// }
//
// public void setNumbers(double[] numbers) {
// this.numbers = numbers;
// }
// }
| import org.ugeojson.model.BoundingBoxDto;
import org.ugeojson.model.PositionDto;
import com.google.gson.JsonDeserializationContext;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject; | package org.ugeojson.parser.util;
/**
* @author moksuzer
*
*/
public class BoundingBoxParser {
private static final int TWO_DIMENSIONAL_BBOX_LENGTH = 4;
private BoundingBoxParser() {
}
| // Path: ugeojson-model/src/main/java/org/ugeojson/model/BoundingBoxDto.java
// public class BoundingBoxDto implements Serializable {
//
// private static final long serialVersionUID = 1L;
//
// private PositionDto southWestCorner;
// private PositionDto northEastCorner;
//
// public PositionDto getSouthWestCorner() {
// return southWestCorner;
// }
//
// public void setSouthWestCorner(PositionDto southWestCorner) {
// this.southWestCorner = southWestCorner;
// }
//
// public PositionDto getNorthEastCorner() {
// return northEastCorner;
// }
//
// public void setNorthEastCorner(PositionDto northEastCorner) {
// this.northEastCorner = northEastCorner;
// }
//
// }
//
// Path: ugeojson-model/src/main/java/org/ugeojson/model/PositionDto.java
// public class PositionDto implements Serializable {
//
// private static final long serialVersionUID = 1L;
//
// private double[] numbers;
//
// /**
// * This constructor initializes numbers field to hold two double numbers. Do
// * not use this constructor if you need the third elevation parameter.
// */
// public PositionDto() {
// this.numbers = new double[2];
// }
//
// /**
// * Simple coordinate position constructor
// *
// * @param longitude
// * @param latitude
// */
// public PositionDto(double longitude, double latitude) {
// this.numbers = new double[] { longitude, latitude };
// }
//
// /**
// * Use this constructor if you need elevation parameter
// *
// * @param longitude
// * @param latitude
// * @param elevation
// */
// public PositionDto(double longitude, double latitude, double elevation) {
// this.numbers = new double[] { longitude, latitude, elevation };
// }
//
// /**
// * Copy constructor
// *
// * @param position
// */
// public PositionDto(PositionDto position) {
// if (position != null) {
// double[] copyNumbers = position.getNumbers();
// this.numbers = new double[copyNumbers.length];
// for (int i = 0; i < copyNumbers.length; i++) {
// this.numbers[i] = copyNumbers[i];
// }
// }
// }
//
// @Override
// public String toString() {
// if (numbers == null) {
// return "null numbers[]";
// }
// StringBuilder value = new StringBuilder("[");
// for (int i = 0; i < numbers.length; i++) {
// value.append(numbers[i]);
// if (i < numbers.length - 1) {
// value.append(", ");
// }
// }
// value.append("]");
// return value.toString();
// }
//
// public void setLongitude(double longitude) {
// this.numbers[0] = longitude;
// }
//
// public double getLongitude() {
// return numbers[0];
// }
//
// public void setLatitude(double latitude) {
// this.numbers[1] = latitude;
// }
//
// public double getLatitude() {
// return numbers[1];
// }
//
// public void setElevation(double elevation) {
// this.numbers[2] = elevation;
// }
//
// public double getElevation() {
// return numbers[2];
// }
//
// public double[] getNumbers() {
// return numbers;
// }
//
// public void setNumbers(double[] numbers) {
// this.numbers = numbers;
// }
// }
// Path: ugeojson-parser/src/main/java/org/ugeojson/parser/util/BoundingBoxParser.java
import org.ugeojson.model.BoundingBoxDto;
import org.ugeojson.model.PositionDto;
import com.google.gson.JsonDeserializationContext;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
package org.ugeojson.parser.util;
/**
* @author moksuzer
*
*/
public class BoundingBoxParser {
private static final int TWO_DIMENSIONAL_BBOX_LENGTH = 4;
private BoundingBoxParser() {
}
| public static BoundingBoxDto parseBbox(JsonObject asJsonObject, JsonDeserializationContext context) { |
mokszr/ultimate-geojson | ugeojson-parser/src/main/java/org/ugeojson/parser/util/BoundingBoxParser.java | // Path: ugeojson-model/src/main/java/org/ugeojson/model/BoundingBoxDto.java
// public class BoundingBoxDto implements Serializable {
//
// private static final long serialVersionUID = 1L;
//
// private PositionDto southWestCorner;
// private PositionDto northEastCorner;
//
// public PositionDto getSouthWestCorner() {
// return southWestCorner;
// }
//
// public void setSouthWestCorner(PositionDto southWestCorner) {
// this.southWestCorner = southWestCorner;
// }
//
// public PositionDto getNorthEastCorner() {
// return northEastCorner;
// }
//
// public void setNorthEastCorner(PositionDto northEastCorner) {
// this.northEastCorner = northEastCorner;
// }
//
// }
//
// Path: ugeojson-model/src/main/java/org/ugeojson/model/PositionDto.java
// public class PositionDto implements Serializable {
//
// private static final long serialVersionUID = 1L;
//
// private double[] numbers;
//
// /**
// * This constructor initializes numbers field to hold two double numbers. Do
// * not use this constructor if you need the third elevation parameter.
// */
// public PositionDto() {
// this.numbers = new double[2];
// }
//
// /**
// * Simple coordinate position constructor
// *
// * @param longitude
// * @param latitude
// */
// public PositionDto(double longitude, double latitude) {
// this.numbers = new double[] { longitude, latitude };
// }
//
// /**
// * Use this constructor if you need elevation parameter
// *
// * @param longitude
// * @param latitude
// * @param elevation
// */
// public PositionDto(double longitude, double latitude, double elevation) {
// this.numbers = new double[] { longitude, latitude, elevation };
// }
//
// /**
// * Copy constructor
// *
// * @param position
// */
// public PositionDto(PositionDto position) {
// if (position != null) {
// double[] copyNumbers = position.getNumbers();
// this.numbers = new double[copyNumbers.length];
// for (int i = 0; i < copyNumbers.length; i++) {
// this.numbers[i] = copyNumbers[i];
// }
// }
// }
//
// @Override
// public String toString() {
// if (numbers == null) {
// return "null numbers[]";
// }
// StringBuilder value = new StringBuilder("[");
// for (int i = 0; i < numbers.length; i++) {
// value.append(numbers[i]);
// if (i < numbers.length - 1) {
// value.append(", ");
// }
// }
// value.append("]");
// return value.toString();
// }
//
// public void setLongitude(double longitude) {
// this.numbers[0] = longitude;
// }
//
// public double getLongitude() {
// return numbers[0];
// }
//
// public void setLatitude(double latitude) {
// this.numbers[1] = latitude;
// }
//
// public double getLatitude() {
// return numbers[1];
// }
//
// public void setElevation(double elevation) {
// this.numbers[2] = elevation;
// }
//
// public double getElevation() {
// return numbers[2];
// }
//
// public double[] getNumbers() {
// return numbers;
// }
//
// public void setNumbers(double[] numbers) {
// this.numbers = numbers;
// }
// }
| import org.ugeojson.model.BoundingBoxDto;
import org.ugeojson.model.PositionDto;
import com.google.gson.JsonDeserializationContext;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject; | package org.ugeojson.parser.util;
/**
* @author moksuzer
*
*/
public class BoundingBoxParser {
private static final int TWO_DIMENSIONAL_BBOX_LENGTH = 4;
private BoundingBoxParser() {
}
public static BoundingBoxDto parseBbox(JsonObject asJsonObject, JsonDeserializationContext context) {
BoundingBoxDto bboxDto = null;
JsonElement bboxElement = asJsonObject.get("bbox");
if (bboxElement != null) {
double[] bbox = context.deserialize(bboxElement, double[].class);
bboxDto = new BoundingBoxDto();
if (bbox.length == TWO_DIMENSIONAL_BBOX_LENGTH) { | // Path: ugeojson-model/src/main/java/org/ugeojson/model/BoundingBoxDto.java
// public class BoundingBoxDto implements Serializable {
//
// private static final long serialVersionUID = 1L;
//
// private PositionDto southWestCorner;
// private PositionDto northEastCorner;
//
// public PositionDto getSouthWestCorner() {
// return southWestCorner;
// }
//
// public void setSouthWestCorner(PositionDto southWestCorner) {
// this.southWestCorner = southWestCorner;
// }
//
// public PositionDto getNorthEastCorner() {
// return northEastCorner;
// }
//
// public void setNorthEastCorner(PositionDto northEastCorner) {
// this.northEastCorner = northEastCorner;
// }
//
// }
//
// Path: ugeojson-model/src/main/java/org/ugeojson/model/PositionDto.java
// public class PositionDto implements Serializable {
//
// private static final long serialVersionUID = 1L;
//
// private double[] numbers;
//
// /**
// * This constructor initializes numbers field to hold two double numbers. Do
// * not use this constructor if you need the third elevation parameter.
// */
// public PositionDto() {
// this.numbers = new double[2];
// }
//
// /**
// * Simple coordinate position constructor
// *
// * @param longitude
// * @param latitude
// */
// public PositionDto(double longitude, double latitude) {
// this.numbers = new double[] { longitude, latitude };
// }
//
// /**
// * Use this constructor if you need elevation parameter
// *
// * @param longitude
// * @param latitude
// * @param elevation
// */
// public PositionDto(double longitude, double latitude, double elevation) {
// this.numbers = new double[] { longitude, latitude, elevation };
// }
//
// /**
// * Copy constructor
// *
// * @param position
// */
// public PositionDto(PositionDto position) {
// if (position != null) {
// double[] copyNumbers = position.getNumbers();
// this.numbers = new double[copyNumbers.length];
// for (int i = 0; i < copyNumbers.length; i++) {
// this.numbers[i] = copyNumbers[i];
// }
// }
// }
//
// @Override
// public String toString() {
// if (numbers == null) {
// return "null numbers[]";
// }
// StringBuilder value = new StringBuilder("[");
// for (int i = 0; i < numbers.length; i++) {
// value.append(numbers[i]);
// if (i < numbers.length - 1) {
// value.append(", ");
// }
// }
// value.append("]");
// return value.toString();
// }
//
// public void setLongitude(double longitude) {
// this.numbers[0] = longitude;
// }
//
// public double getLongitude() {
// return numbers[0];
// }
//
// public void setLatitude(double latitude) {
// this.numbers[1] = latitude;
// }
//
// public double getLatitude() {
// return numbers[1];
// }
//
// public void setElevation(double elevation) {
// this.numbers[2] = elevation;
// }
//
// public double getElevation() {
// return numbers[2];
// }
//
// public double[] getNumbers() {
// return numbers;
// }
//
// public void setNumbers(double[] numbers) {
// this.numbers = numbers;
// }
// }
// Path: ugeojson-parser/src/main/java/org/ugeojson/parser/util/BoundingBoxParser.java
import org.ugeojson.model.BoundingBoxDto;
import org.ugeojson.model.PositionDto;
import com.google.gson.JsonDeserializationContext;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
package org.ugeojson.parser.util;
/**
* @author moksuzer
*
*/
public class BoundingBoxParser {
private static final int TWO_DIMENSIONAL_BBOX_LENGTH = 4;
private BoundingBoxParser() {
}
public static BoundingBoxDto parseBbox(JsonObject asJsonObject, JsonDeserializationContext context) {
BoundingBoxDto bboxDto = null;
JsonElement bboxElement = asJsonObject.get("bbox");
if (bboxElement != null) {
double[] bbox = context.deserialize(bboxElement, double[].class);
bboxDto = new BoundingBoxDto();
if (bbox.length == TWO_DIMENSIONAL_BBOX_LENGTH) { | bboxDto.setSouthWestCorner(new PositionDto(bbox[0], bbox[1])); |
mokszr/ultimate-geojson | ugeojson-model/src/main/java/org/ugeojson/model/geometry/PointDto.java | // Path: ugeojson-model/src/main/java/org/ugeojson/model/GeoJSONObjectTypeEnum.java
// public enum GeoJSONObjectTypeEnum {
//
// Point(PointDto.class), MultiPoint(MultiPointDto.class), LineString(LineStringDto.class), MultiLineString(
// MultiLineStringDto.class), Polygon(PolygonDto.class), MultiPolygon(
// MultiPolygonDto.class), GeometryCollection(GeometryCollectionDto.class), Feature(
// FeatureDto.class), FeatureCollection(FeatureCollectionDto.class);
//
// private final Class dtoClass;
//
// private GeoJSONObjectTypeEnum(Class dtoClass) {
// this.dtoClass = dtoClass;
// }
//
// public Class getDtoClass() {
// return dtoClass;
// }
// }
//
// Path: ugeojson-model/src/main/java/org/ugeojson/model/PositionDto.java
// public class PositionDto implements Serializable {
//
// private static final long serialVersionUID = 1L;
//
// private double[] numbers;
//
// /**
// * This constructor initializes numbers field to hold two double numbers. Do
// * not use this constructor if you need the third elevation parameter.
// */
// public PositionDto() {
// this.numbers = new double[2];
// }
//
// /**
// * Simple coordinate position constructor
// *
// * @param longitude
// * @param latitude
// */
// public PositionDto(double longitude, double latitude) {
// this.numbers = new double[] { longitude, latitude };
// }
//
// /**
// * Use this constructor if you need elevation parameter
// *
// * @param longitude
// * @param latitude
// * @param elevation
// */
// public PositionDto(double longitude, double latitude, double elevation) {
// this.numbers = new double[] { longitude, latitude, elevation };
// }
//
// /**
// * Copy constructor
// *
// * @param position
// */
// public PositionDto(PositionDto position) {
// if (position != null) {
// double[] copyNumbers = position.getNumbers();
// this.numbers = new double[copyNumbers.length];
// for (int i = 0; i < copyNumbers.length; i++) {
// this.numbers[i] = copyNumbers[i];
// }
// }
// }
//
// @Override
// public String toString() {
// if (numbers == null) {
// return "null numbers[]";
// }
// StringBuilder value = new StringBuilder("[");
// for (int i = 0; i < numbers.length; i++) {
// value.append(numbers[i]);
// if (i < numbers.length - 1) {
// value.append(", ");
// }
// }
// value.append("]");
// return value.toString();
// }
//
// public void setLongitude(double longitude) {
// this.numbers[0] = longitude;
// }
//
// public double getLongitude() {
// return numbers[0];
// }
//
// public void setLatitude(double latitude) {
// this.numbers[1] = latitude;
// }
//
// public double getLatitude() {
// return numbers[1];
// }
//
// public void setElevation(double elevation) {
// this.numbers[2] = elevation;
// }
//
// public double getElevation() {
// return numbers[2];
// }
//
// public double[] getNumbers() {
// return numbers;
// }
//
// public void setNumbers(double[] numbers) {
// this.numbers = numbers;
// }
// }
| import org.ugeojson.model.GeoJSONObjectTypeEnum;
import org.ugeojson.model.PositionDto; | package org.ugeojson.model.geometry;
/**
* @author moksuzer
*
*/
public class PointDto extends GeometryDto {
private static final long serialVersionUID = 1L;
| // Path: ugeojson-model/src/main/java/org/ugeojson/model/GeoJSONObjectTypeEnum.java
// public enum GeoJSONObjectTypeEnum {
//
// Point(PointDto.class), MultiPoint(MultiPointDto.class), LineString(LineStringDto.class), MultiLineString(
// MultiLineStringDto.class), Polygon(PolygonDto.class), MultiPolygon(
// MultiPolygonDto.class), GeometryCollection(GeometryCollectionDto.class), Feature(
// FeatureDto.class), FeatureCollection(FeatureCollectionDto.class);
//
// private final Class dtoClass;
//
// private GeoJSONObjectTypeEnum(Class dtoClass) {
// this.dtoClass = dtoClass;
// }
//
// public Class getDtoClass() {
// return dtoClass;
// }
// }
//
// Path: ugeojson-model/src/main/java/org/ugeojson/model/PositionDto.java
// public class PositionDto implements Serializable {
//
// private static final long serialVersionUID = 1L;
//
// private double[] numbers;
//
// /**
// * This constructor initializes numbers field to hold two double numbers. Do
// * not use this constructor if you need the third elevation parameter.
// */
// public PositionDto() {
// this.numbers = new double[2];
// }
//
// /**
// * Simple coordinate position constructor
// *
// * @param longitude
// * @param latitude
// */
// public PositionDto(double longitude, double latitude) {
// this.numbers = new double[] { longitude, latitude };
// }
//
// /**
// * Use this constructor if you need elevation parameter
// *
// * @param longitude
// * @param latitude
// * @param elevation
// */
// public PositionDto(double longitude, double latitude, double elevation) {
// this.numbers = new double[] { longitude, latitude, elevation };
// }
//
// /**
// * Copy constructor
// *
// * @param position
// */
// public PositionDto(PositionDto position) {
// if (position != null) {
// double[] copyNumbers = position.getNumbers();
// this.numbers = new double[copyNumbers.length];
// for (int i = 0; i < copyNumbers.length; i++) {
// this.numbers[i] = copyNumbers[i];
// }
// }
// }
//
// @Override
// public String toString() {
// if (numbers == null) {
// return "null numbers[]";
// }
// StringBuilder value = new StringBuilder("[");
// for (int i = 0; i < numbers.length; i++) {
// value.append(numbers[i]);
// if (i < numbers.length - 1) {
// value.append(", ");
// }
// }
// value.append("]");
// return value.toString();
// }
//
// public void setLongitude(double longitude) {
// this.numbers[0] = longitude;
// }
//
// public double getLongitude() {
// return numbers[0];
// }
//
// public void setLatitude(double latitude) {
// this.numbers[1] = latitude;
// }
//
// public double getLatitude() {
// return numbers[1];
// }
//
// public void setElevation(double elevation) {
// this.numbers[2] = elevation;
// }
//
// public double getElevation() {
// return numbers[2];
// }
//
// public double[] getNumbers() {
// return numbers;
// }
//
// public void setNumbers(double[] numbers) {
// this.numbers = numbers;
// }
// }
// Path: ugeojson-model/src/main/java/org/ugeojson/model/geometry/PointDto.java
import org.ugeojson.model.GeoJSONObjectTypeEnum;
import org.ugeojson.model.PositionDto;
package org.ugeojson.model.geometry;
/**
* @author moksuzer
*
*/
public class PointDto extends GeometryDto {
private static final long serialVersionUID = 1L;
| private PositionDto position; |
mokszr/ultimate-geojson | ugeojson-model/src/main/java/org/ugeojson/model/geometry/PointDto.java | // Path: ugeojson-model/src/main/java/org/ugeojson/model/GeoJSONObjectTypeEnum.java
// public enum GeoJSONObjectTypeEnum {
//
// Point(PointDto.class), MultiPoint(MultiPointDto.class), LineString(LineStringDto.class), MultiLineString(
// MultiLineStringDto.class), Polygon(PolygonDto.class), MultiPolygon(
// MultiPolygonDto.class), GeometryCollection(GeometryCollectionDto.class), Feature(
// FeatureDto.class), FeatureCollection(FeatureCollectionDto.class);
//
// private final Class dtoClass;
//
// private GeoJSONObjectTypeEnum(Class dtoClass) {
// this.dtoClass = dtoClass;
// }
//
// public Class getDtoClass() {
// return dtoClass;
// }
// }
//
// Path: ugeojson-model/src/main/java/org/ugeojson/model/PositionDto.java
// public class PositionDto implements Serializable {
//
// private static final long serialVersionUID = 1L;
//
// private double[] numbers;
//
// /**
// * This constructor initializes numbers field to hold two double numbers. Do
// * not use this constructor if you need the third elevation parameter.
// */
// public PositionDto() {
// this.numbers = new double[2];
// }
//
// /**
// * Simple coordinate position constructor
// *
// * @param longitude
// * @param latitude
// */
// public PositionDto(double longitude, double latitude) {
// this.numbers = new double[] { longitude, latitude };
// }
//
// /**
// * Use this constructor if you need elevation parameter
// *
// * @param longitude
// * @param latitude
// * @param elevation
// */
// public PositionDto(double longitude, double latitude, double elevation) {
// this.numbers = new double[] { longitude, latitude, elevation };
// }
//
// /**
// * Copy constructor
// *
// * @param position
// */
// public PositionDto(PositionDto position) {
// if (position != null) {
// double[] copyNumbers = position.getNumbers();
// this.numbers = new double[copyNumbers.length];
// for (int i = 0; i < copyNumbers.length; i++) {
// this.numbers[i] = copyNumbers[i];
// }
// }
// }
//
// @Override
// public String toString() {
// if (numbers == null) {
// return "null numbers[]";
// }
// StringBuilder value = new StringBuilder("[");
// for (int i = 0; i < numbers.length; i++) {
// value.append(numbers[i]);
// if (i < numbers.length - 1) {
// value.append(", ");
// }
// }
// value.append("]");
// return value.toString();
// }
//
// public void setLongitude(double longitude) {
// this.numbers[0] = longitude;
// }
//
// public double getLongitude() {
// return numbers[0];
// }
//
// public void setLatitude(double latitude) {
// this.numbers[1] = latitude;
// }
//
// public double getLatitude() {
// return numbers[1];
// }
//
// public void setElevation(double elevation) {
// this.numbers[2] = elevation;
// }
//
// public double getElevation() {
// return numbers[2];
// }
//
// public double[] getNumbers() {
// return numbers;
// }
//
// public void setNumbers(double[] numbers) {
// this.numbers = numbers;
// }
// }
| import org.ugeojson.model.GeoJSONObjectTypeEnum;
import org.ugeojson.model.PositionDto; |
public void setLongitude(double longitude) {
this.position.setLongitude(longitude);
}
public double getLatitude() {
return this.position.getLatitude();
}
public void setLatitude(double latitude) {
this.position.setLatitude(latitude);
}
public void setElevation(double elevation) {
this.position.setElevation(elevation);
}
public double getElevation() {
return this.position.getElevation();
}
public PositionDto getPosition() {
return position;
}
public void setPosition(PositionDto position) {
this.position = position;
}
@Override | // Path: ugeojson-model/src/main/java/org/ugeojson/model/GeoJSONObjectTypeEnum.java
// public enum GeoJSONObjectTypeEnum {
//
// Point(PointDto.class), MultiPoint(MultiPointDto.class), LineString(LineStringDto.class), MultiLineString(
// MultiLineStringDto.class), Polygon(PolygonDto.class), MultiPolygon(
// MultiPolygonDto.class), GeometryCollection(GeometryCollectionDto.class), Feature(
// FeatureDto.class), FeatureCollection(FeatureCollectionDto.class);
//
// private final Class dtoClass;
//
// private GeoJSONObjectTypeEnum(Class dtoClass) {
// this.dtoClass = dtoClass;
// }
//
// public Class getDtoClass() {
// return dtoClass;
// }
// }
//
// Path: ugeojson-model/src/main/java/org/ugeojson/model/PositionDto.java
// public class PositionDto implements Serializable {
//
// private static final long serialVersionUID = 1L;
//
// private double[] numbers;
//
// /**
// * This constructor initializes numbers field to hold two double numbers. Do
// * not use this constructor if you need the third elevation parameter.
// */
// public PositionDto() {
// this.numbers = new double[2];
// }
//
// /**
// * Simple coordinate position constructor
// *
// * @param longitude
// * @param latitude
// */
// public PositionDto(double longitude, double latitude) {
// this.numbers = new double[] { longitude, latitude };
// }
//
// /**
// * Use this constructor if you need elevation parameter
// *
// * @param longitude
// * @param latitude
// * @param elevation
// */
// public PositionDto(double longitude, double latitude, double elevation) {
// this.numbers = new double[] { longitude, latitude, elevation };
// }
//
// /**
// * Copy constructor
// *
// * @param position
// */
// public PositionDto(PositionDto position) {
// if (position != null) {
// double[] copyNumbers = position.getNumbers();
// this.numbers = new double[copyNumbers.length];
// for (int i = 0; i < copyNumbers.length; i++) {
// this.numbers[i] = copyNumbers[i];
// }
// }
// }
//
// @Override
// public String toString() {
// if (numbers == null) {
// return "null numbers[]";
// }
// StringBuilder value = new StringBuilder("[");
// for (int i = 0; i < numbers.length; i++) {
// value.append(numbers[i]);
// if (i < numbers.length - 1) {
// value.append(", ");
// }
// }
// value.append("]");
// return value.toString();
// }
//
// public void setLongitude(double longitude) {
// this.numbers[0] = longitude;
// }
//
// public double getLongitude() {
// return numbers[0];
// }
//
// public void setLatitude(double latitude) {
// this.numbers[1] = latitude;
// }
//
// public double getLatitude() {
// return numbers[1];
// }
//
// public void setElevation(double elevation) {
// this.numbers[2] = elevation;
// }
//
// public double getElevation() {
// return numbers[2];
// }
//
// public double[] getNumbers() {
// return numbers;
// }
//
// public void setNumbers(double[] numbers) {
// this.numbers = numbers;
// }
// }
// Path: ugeojson-model/src/main/java/org/ugeojson/model/geometry/PointDto.java
import org.ugeojson.model.GeoJSONObjectTypeEnum;
import org.ugeojson.model.PositionDto;
public void setLongitude(double longitude) {
this.position.setLongitude(longitude);
}
public double getLatitude() {
return this.position.getLatitude();
}
public void setLatitude(double latitude) {
this.position.setLatitude(latitude);
}
public void setElevation(double elevation) {
this.position.setElevation(elevation);
}
public double getElevation() {
return this.position.getElevation();
}
public PositionDto getPosition() {
return position;
}
public void setPosition(PositionDto position) {
this.position = position;
}
@Override | public GeoJSONObjectTypeEnum getGeoJSONObjectType() { |
mokszr/ultimate-geojson | ugeojson-model/src/main/java/org/ugeojson/model/geometry/PolygonDto.java | // Path: ugeojson-model/src/main/java/org/ugeojson/model/GeoJSONObjectTypeEnum.java
// public enum GeoJSONObjectTypeEnum {
//
// Point(PointDto.class), MultiPoint(MultiPointDto.class), LineString(LineStringDto.class), MultiLineString(
// MultiLineStringDto.class), Polygon(PolygonDto.class), MultiPolygon(
// MultiPolygonDto.class), GeometryCollection(GeometryCollectionDto.class), Feature(
// FeatureDto.class), FeatureCollection(FeatureCollectionDto.class);
//
// private final Class dtoClass;
//
// private GeoJSONObjectTypeEnum(Class dtoClass) {
// this.dtoClass = dtoClass;
// }
//
// public Class getDtoClass() {
// return dtoClass;
// }
// }
| import java.util.List;
import org.ugeojson.model.GeoJSONObjectTypeEnum; | package org.ugeojson.model.geometry;
/**
* @author moksuzer
*
*/
public class PolygonDto extends GeometryDto {
private static final long serialVersionUID = 1L;
private List<LineStringDto> linearRings;
@Override | // Path: ugeojson-model/src/main/java/org/ugeojson/model/GeoJSONObjectTypeEnum.java
// public enum GeoJSONObjectTypeEnum {
//
// Point(PointDto.class), MultiPoint(MultiPointDto.class), LineString(LineStringDto.class), MultiLineString(
// MultiLineStringDto.class), Polygon(PolygonDto.class), MultiPolygon(
// MultiPolygonDto.class), GeometryCollection(GeometryCollectionDto.class), Feature(
// FeatureDto.class), FeatureCollection(FeatureCollectionDto.class);
//
// private final Class dtoClass;
//
// private GeoJSONObjectTypeEnum(Class dtoClass) {
// this.dtoClass = dtoClass;
// }
//
// public Class getDtoClass() {
// return dtoClass;
// }
// }
// Path: ugeojson-model/src/main/java/org/ugeojson/model/geometry/PolygonDto.java
import java.util.List;
import org.ugeojson.model.GeoJSONObjectTypeEnum;
package org.ugeojson.model.geometry;
/**
* @author moksuzer
*
*/
public class PolygonDto extends GeometryDto {
private static final long serialVersionUID = 1L;
private List<LineStringDto> linearRings;
@Override | public GeoJSONObjectTypeEnum getGeoJSONObjectType() { |
mokszr/ultimate-geojson | ugeojson-parser/src/main/java/org/ugeojson/parser/deserializer/FeatureDeserializer.java | // Path: ugeojson-model/src/main/java/org/ugeojson/model/GeoJSONObjectTypeEnum.java
// public enum GeoJSONObjectTypeEnum {
//
// Point(PointDto.class), MultiPoint(MultiPointDto.class), LineString(LineStringDto.class), MultiLineString(
// MultiLineStringDto.class), Polygon(PolygonDto.class), MultiPolygon(
// MultiPolygonDto.class), GeometryCollection(GeometryCollectionDto.class), Feature(
// FeatureDto.class), FeatureCollection(FeatureCollectionDto.class);
//
// private final Class dtoClass;
//
// private GeoJSONObjectTypeEnum(Class dtoClass) {
// this.dtoClass = dtoClass;
// }
//
// public Class getDtoClass() {
// return dtoClass;
// }
// }
//
// Path: ugeojson-model/src/main/java/org/ugeojson/model/feature/FeatureDto.java
// public class FeatureDto extends GeoJSONObjectDto {
//
// private static final long serialVersionUID = 1L;
//
// private GeometryDto geometry;
// private String properties;
// private String id;
//
// @Override
// public GeoJSONObjectTypeEnum getGeoJSONObjectType() {
// return GeoJSONObjectTypeEnum.Feature;
// }
//
// public GeometryDto getGeometry() {
// return geometry;
// }
//
// public void setGeometry(GeometryDto geometry) {
// this.geometry = geometry;
// }
//
// public String getProperties() {
// return properties;
// }
//
// public void setProperties(String properties) {
// this.properties = properties;
// }
//
// public String getId() {
// return id;
// }
//
// public void setId(String id) {
// this.id = id;
// }
//
// }
//
// Path: ugeojson-model/src/main/java/org/ugeojson/model/geometry/GeometryDto.java
// public abstract class GeometryDto extends GeoJSONObjectDto {
//
// private static final long serialVersionUID = 1L;
//
// }
//
// Path: ugeojson-parser/src/main/java/org/ugeojson/parser/util/BoundingBoxParser.java
// public class BoundingBoxParser {
//
// private static final int TWO_DIMENSIONAL_BBOX_LENGTH = 4;
//
// private BoundingBoxParser() {
// }
//
// public static BoundingBoxDto parseBbox(JsonObject asJsonObject, JsonDeserializationContext context) {
// BoundingBoxDto bboxDto = null;
// JsonElement bboxElement = asJsonObject.get("bbox");
// if (bboxElement != null) {
// double[] bbox = context.deserialize(bboxElement, double[].class);
// bboxDto = new BoundingBoxDto();
// if (bbox.length == TWO_DIMENSIONAL_BBOX_LENGTH) {
// bboxDto.setSouthWestCorner(new PositionDto(bbox[0], bbox[1]));
// bboxDto.setNorthEastCorner(new PositionDto(bbox[2], bbox[3]));
// } else {
// bboxDto.setSouthWestCorner(new PositionDto(bbox[0], bbox[1], bbox[2]));
// bboxDto.setNorthEastCorner(new PositionDto(bbox[3], bbox[4], bbox[5]));
// }
//
// }
// return bboxDto;
// }
//
// }
| import java.lang.reflect.Type;
import org.ugeojson.model.GeoJSONObjectTypeEnum;
import org.ugeojson.model.feature.FeatureDto;
import org.ugeojson.model.geometry.GeometryDto;
import org.ugeojson.parser.util.BoundingBoxParser;
import com.google.gson.JsonDeserializationContext;
import com.google.gson.JsonDeserializer;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject; | package org.ugeojson.parser.deserializer;
/**
* Deserializer for Feature
*
* @author moksuzer
*
*/
public class FeatureDeserializer implements JsonDeserializer<FeatureDto> {
@Override
public FeatureDto deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) {
FeatureDto dto = new FeatureDto();
JsonObject asJsonObject = json.getAsJsonObject();
JsonElement geometryElement = asJsonObject.get("geometry");
if (geometryElement != null) {
String typeOfGeometry = geometryElement.getAsJsonObject().get("type").getAsString(); | // Path: ugeojson-model/src/main/java/org/ugeojson/model/GeoJSONObjectTypeEnum.java
// public enum GeoJSONObjectTypeEnum {
//
// Point(PointDto.class), MultiPoint(MultiPointDto.class), LineString(LineStringDto.class), MultiLineString(
// MultiLineStringDto.class), Polygon(PolygonDto.class), MultiPolygon(
// MultiPolygonDto.class), GeometryCollection(GeometryCollectionDto.class), Feature(
// FeatureDto.class), FeatureCollection(FeatureCollectionDto.class);
//
// private final Class dtoClass;
//
// private GeoJSONObjectTypeEnum(Class dtoClass) {
// this.dtoClass = dtoClass;
// }
//
// public Class getDtoClass() {
// return dtoClass;
// }
// }
//
// Path: ugeojson-model/src/main/java/org/ugeojson/model/feature/FeatureDto.java
// public class FeatureDto extends GeoJSONObjectDto {
//
// private static final long serialVersionUID = 1L;
//
// private GeometryDto geometry;
// private String properties;
// private String id;
//
// @Override
// public GeoJSONObjectTypeEnum getGeoJSONObjectType() {
// return GeoJSONObjectTypeEnum.Feature;
// }
//
// public GeometryDto getGeometry() {
// return geometry;
// }
//
// public void setGeometry(GeometryDto geometry) {
// this.geometry = geometry;
// }
//
// public String getProperties() {
// return properties;
// }
//
// public void setProperties(String properties) {
// this.properties = properties;
// }
//
// public String getId() {
// return id;
// }
//
// public void setId(String id) {
// this.id = id;
// }
//
// }
//
// Path: ugeojson-model/src/main/java/org/ugeojson/model/geometry/GeometryDto.java
// public abstract class GeometryDto extends GeoJSONObjectDto {
//
// private static final long serialVersionUID = 1L;
//
// }
//
// Path: ugeojson-parser/src/main/java/org/ugeojson/parser/util/BoundingBoxParser.java
// public class BoundingBoxParser {
//
// private static final int TWO_DIMENSIONAL_BBOX_LENGTH = 4;
//
// private BoundingBoxParser() {
// }
//
// public static BoundingBoxDto parseBbox(JsonObject asJsonObject, JsonDeserializationContext context) {
// BoundingBoxDto bboxDto = null;
// JsonElement bboxElement = asJsonObject.get("bbox");
// if (bboxElement != null) {
// double[] bbox = context.deserialize(bboxElement, double[].class);
// bboxDto = new BoundingBoxDto();
// if (bbox.length == TWO_DIMENSIONAL_BBOX_LENGTH) {
// bboxDto.setSouthWestCorner(new PositionDto(bbox[0], bbox[1]));
// bboxDto.setNorthEastCorner(new PositionDto(bbox[2], bbox[3]));
// } else {
// bboxDto.setSouthWestCorner(new PositionDto(bbox[0], bbox[1], bbox[2]));
// bboxDto.setNorthEastCorner(new PositionDto(bbox[3], bbox[4], bbox[5]));
// }
//
// }
// return bboxDto;
// }
//
// }
// Path: ugeojson-parser/src/main/java/org/ugeojson/parser/deserializer/FeatureDeserializer.java
import java.lang.reflect.Type;
import org.ugeojson.model.GeoJSONObjectTypeEnum;
import org.ugeojson.model.feature.FeatureDto;
import org.ugeojson.model.geometry.GeometryDto;
import org.ugeojson.parser.util.BoundingBoxParser;
import com.google.gson.JsonDeserializationContext;
import com.google.gson.JsonDeserializer;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
package org.ugeojson.parser.deserializer;
/**
* Deserializer for Feature
*
* @author moksuzer
*
*/
public class FeatureDeserializer implements JsonDeserializer<FeatureDto> {
@Override
public FeatureDto deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) {
FeatureDto dto = new FeatureDto();
JsonObject asJsonObject = json.getAsJsonObject();
JsonElement geometryElement = asJsonObject.get("geometry");
if (geometryElement != null) {
String typeOfGeometry = geometryElement.getAsJsonObject().get("type").getAsString(); | GeoJSONObjectTypeEnum typeEnum = GeoJSONObjectTypeEnum.valueOf(typeOfGeometry); |
mokszr/ultimate-geojson | ugeojson-parser/src/main/java/org/ugeojson/parser/deserializer/FeatureDeserializer.java | // Path: ugeojson-model/src/main/java/org/ugeojson/model/GeoJSONObjectTypeEnum.java
// public enum GeoJSONObjectTypeEnum {
//
// Point(PointDto.class), MultiPoint(MultiPointDto.class), LineString(LineStringDto.class), MultiLineString(
// MultiLineStringDto.class), Polygon(PolygonDto.class), MultiPolygon(
// MultiPolygonDto.class), GeometryCollection(GeometryCollectionDto.class), Feature(
// FeatureDto.class), FeatureCollection(FeatureCollectionDto.class);
//
// private final Class dtoClass;
//
// private GeoJSONObjectTypeEnum(Class dtoClass) {
// this.dtoClass = dtoClass;
// }
//
// public Class getDtoClass() {
// return dtoClass;
// }
// }
//
// Path: ugeojson-model/src/main/java/org/ugeojson/model/feature/FeatureDto.java
// public class FeatureDto extends GeoJSONObjectDto {
//
// private static final long serialVersionUID = 1L;
//
// private GeometryDto geometry;
// private String properties;
// private String id;
//
// @Override
// public GeoJSONObjectTypeEnum getGeoJSONObjectType() {
// return GeoJSONObjectTypeEnum.Feature;
// }
//
// public GeometryDto getGeometry() {
// return geometry;
// }
//
// public void setGeometry(GeometryDto geometry) {
// this.geometry = geometry;
// }
//
// public String getProperties() {
// return properties;
// }
//
// public void setProperties(String properties) {
// this.properties = properties;
// }
//
// public String getId() {
// return id;
// }
//
// public void setId(String id) {
// this.id = id;
// }
//
// }
//
// Path: ugeojson-model/src/main/java/org/ugeojson/model/geometry/GeometryDto.java
// public abstract class GeometryDto extends GeoJSONObjectDto {
//
// private static final long serialVersionUID = 1L;
//
// }
//
// Path: ugeojson-parser/src/main/java/org/ugeojson/parser/util/BoundingBoxParser.java
// public class BoundingBoxParser {
//
// private static final int TWO_DIMENSIONAL_BBOX_LENGTH = 4;
//
// private BoundingBoxParser() {
// }
//
// public static BoundingBoxDto parseBbox(JsonObject asJsonObject, JsonDeserializationContext context) {
// BoundingBoxDto bboxDto = null;
// JsonElement bboxElement = asJsonObject.get("bbox");
// if (bboxElement != null) {
// double[] bbox = context.deserialize(bboxElement, double[].class);
// bboxDto = new BoundingBoxDto();
// if (bbox.length == TWO_DIMENSIONAL_BBOX_LENGTH) {
// bboxDto.setSouthWestCorner(new PositionDto(bbox[0], bbox[1]));
// bboxDto.setNorthEastCorner(new PositionDto(bbox[2], bbox[3]));
// } else {
// bboxDto.setSouthWestCorner(new PositionDto(bbox[0], bbox[1], bbox[2]));
// bboxDto.setNorthEastCorner(new PositionDto(bbox[3], bbox[4], bbox[5]));
// }
//
// }
// return bboxDto;
// }
//
// }
| import java.lang.reflect.Type;
import org.ugeojson.model.GeoJSONObjectTypeEnum;
import org.ugeojson.model.feature.FeatureDto;
import org.ugeojson.model.geometry.GeometryDto;
import org.ugeojson.parser.util.BoundingBoxParser;
import com.google.gson.JsonDeserializationContext;
import com.google.gson.JsonDeserializer;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject; | package org.ugeojson.parser.deserializer;
/**
* Deserializer for Feature
*
* @author moksuzer
*
*/
public class FeatureDeserializer implements JsonDeserializer<FeatureDto> {
@Override
public FeatureDto deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) {
FeatureDto dto = new FeatureDto();
JsonObject asJsonObject = json.getAsJsonObject();
JsonElement geometryElement = asJsonObject.get("geometry");
if (geometryElement != null) {
String typeOfGeometry = geometryElement.getAsJsonObject().get("type").getAsString();
GeoJSONObjectTypeEnum typeEnum = GeoJSONObjectTypeEnum.valueOf(typeOfGeometry); | // Path: ugeojson-model/src/main/java/org/ugeojson/model/GeoJSONObjectTypeEnum.java
// public enum GeoJSONObjectTypeEnum {
//
// Point(PointDto.class), MultiPoint(MultiPointDto.class), LineString(LineStringDto.class), MultiLineString(
// MultiLineStringDto.class), Polygon(PolygonDto.class), MultiPolygon(
// MultiPolygonDto.class), GeometryCollection(GeometryCollectionDto.class), Feature(
// FeatureDto.class), FeatureCollection(FeatureCollectionDto.class);
//
// private final Class dtoClass;
//
// private GeoJSONObjectTypeEnum(Class dtoClass) {
// this.dtoClass = dtoClass;
// }
//
// public Class getDtoClass() {
// return dtoClass;
// }
// }
//
// Path: ugeojson-model/src/main/java/org/ugeojson/model/feature/FeatureDto.java
// public class FeatureDto extends GeoJSONObjectDto {
//
// private static final long serialVersionUID = 1L;
//
// private GeometryDto geometry;
// private String properties;
// private String id;
//
// @Override
// public GeoJSONObjectTypeEnum getGeoJSONObjectType() {
// return GeoJSONObjectTypeEnum.Feature;
// }
//
// public GeometryDto getGeometry() {
// return geometry;
// }
//
// public void setGeometry(GeometryDto geometry) {
// this.geometry = geometry;
// }
//
// public String getProperties() {
// return properties;
// }
//
// public void setProperties(String properties) {
// this.properties = properties;
// }
//
// public String getId() {
// return id;
// }
//
// public void setId(String id) {
// this.id = id;
// }
//
// }
//
// Path: ugeojson-model/src/main/java/org/ugeojson/model/geometry/GeometryDto.java
// public abstract class GeometryDto extends GeoJSONObjectDto {
//
// private static final long serialVersionUID = 1L;
//
// }
//
// Path: ugeojson-parser/src/main/java/org/ugeojson/parser/util/BoundingBoxParser.java
// public class BoundingBoxParser {
//
// private static final int TWO_DIMENSIONAL_BBOX_LENGTH = 4;
//
// private BoundingBoxParser() {
// }
//
// public static BoundingBoxDto parseBbox(JsonObject asJsonObject, JsonDeserializationContext context) {
// BoundingBoxDto bboxDto = null;
// JsonElement bboxElement = asJsonObject.get("bbox");
// if (bboxElement != null) {
// double[] bbox = context.deserialize(bboxElement, double[].class);
// bboxDto = new BoundingBoxDto();
// if (bbox.length == TWO_DIMENSIONAL_BBOX_LENGTH) {
// bboxDto.setSouthWestCorner(new PositionDto(bbox[0], bbox[1]));
// bboxDto.setNorthEastCorner(new PositionDto(bbox[2], bbox[3]));
// } else {
// bboxDto.setSouthWestCorner(new PositionDto(bbox[0], bbox[1], bbox[2]));
// bboxDto.setNorthEastCorner(new PositionDto(bbox[3], bbox[4], bbox[5]));
// }
//
// }
// return bboxDto;
// }
//
// }
// Path: ugeojson-parser/src/main/java/org/ugeojson/parser/deserializer/FeatureDeserializer.java
import java.lang.reflect.Type;
import org.ugeojson.model.GeoJSONObjectTypeEnum;
import org.ugeojson.model.feature.FeatureDto;
import org.ugeojson.model.geometry.GeometryDto;
import org.ugeojson.parser.util.BoundingBoxParser;
import com.google.gson.JsonDeserializationContext;
import com.google.gson.JsonDeserializer;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
package org.ugeojson.parser.deserializer;
/**
* Deserializer for Feature
*
* @author moksuzer
*
*/
public class FeatureDeserializer implements JsonDeserializer<FeatureDto> {
@Override
public FeatureDto deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) {
FeatureDto dto = new FeatureDto();
JsonObject asJsonObject = json.getAsJsonObject();
JsonElement geometryElement = asJsonObject.get("geometry");
if (geometryElement != null) {
String typeOfGeometry = geometryElement.getAsJsonObject().get("type").getAsString();
GeoJSONObjectTypeEnum typeEnum = GeoJSONObjectTypeEnum.valueOf(typeOfGeometry); | GeometryDto geometryDto = context.deserialize(geometryElement, typeEnum.getDtoClass()); |
mokszr/ultimate-geojson | ugeojson-parser/src/main/java/org/ugeojson/parser/deserializer/FeatureDeserializer.java | // Path: ugeojson-model/src/main/java/org/ugeojson/model/GeoJSONObjectTypeEnum.java
// public enum GeoJSONObjectTypeEnum {
//
// Point(PointDto.class), MultiPoint(MultiPointDto.class), LineString(LineStringDto.class), MultiLineString(
// MultiLineStringDto.class), Polygon(PolygonDto.class), MultiPolygon(
// MultiPolygonDto.class), GeometryCollection(GeometryCollectionDto.class), Feature(
// FeatureDto.class), FeatureCollection(FeatureCollectionDto.class);
//
// private final Class dtoClass;
//
// private GeoJSONObjectTypeEnum(Class dtoClass) {
// this.dtoClass = dtoClass;
// }
//
// public Class getDtoClass() {
// return dtoClass;
// }
// }
//
// Path: ugeojson-model/src/main/java/org/ugeojson/model/feature/FeatureDto.java
// public class FeatureDto extends GeoJSONObjectDto {
//
// private static final long serialVersionUID = 1L;
//
// private GeometryDto geometry;
// private String properties;
// private String id;
//
// @Override
// public GeoJSONObjectTypeEnum getGeoJSONObjectType() {
// return GeoJSONObjectTypeEnum.Feature;
// }
//
// public GeometryDto getGeometry() {
// return geometry;
// }
//
// public void setGeometry(GeometryDto geometry) {
// this.geometry = geometry;
// }
//
// public String getProperties() {
// return properties;
// }
//
// public void setProperties(String properties) {
// this.properties = properties;
// }
//
// public String getId() {
// return id;
// }
//
// public void setId(String id) {
// this.id = id;
// }
//
// }
//
// Path: ugeojson-model/src/main/java/org/ugeojson/model/geometry/GeometryDto.java
// public abstract class GeometryDto extends GeoJSONObjectDto {
//
// private static final long serialVersionUID = 1L;
//
// }
//
// Path: ugeojson-parser/src/main/java/org/ugeojson/parser/util/BoundingBoxParser.java
// public class BoundingBoxParser {
//
// private static final int TWO_DIMENSIONAL_BBOX_LENGTH = 4;
//
// private BoundingBoxParser() {
// }
//
// public static BoundingBoxDto parseBbox(JsonObject asJsonObject, JsonDeserializationContext context) {
// BoundingBoxDto bboxDto = null;
// JsonElement bboxElement = asJsonObject.get("bbox");
// if (bboxElement != null) {
// double[] bbox = context.deserialize(bboxElement, double[].class);
// bboxDto = new BoundingBoxDto();
// if (bbox.length == TWO_DIMENSIONAL_BBOX_LENGTH) {
// bboxDto.setSouthWestCorner(new PositionDto(bbox[0], bbox[1]));
// bboxDto.setNorthEastCorner(new PositionDto(bbox[2], bbox[3]));
// } else {
// bboxDto.setSouthWestCorner(new PositionDto(bbox[0], bbox[1], bbox[2]));
// bboxDto.setNorthEastCorner(new PositionDto(bbox[3], bbox[4], bbox[5]));
// }
//
// }
// return bboxDto;
// }
//
// }
| import java.lang.reflect.Type;
import org.ugeojson.model.GeoJSONObjectTypeEnum;
import org.ugeojson.model.feature.FeatureDto;
import org.ugeojson.model.geometry.GeometryDto;
import org.ugeojson.parser.util.BoundingBoxParser;
import com.google.gson.JsonDeserializationContext;
import com.google.gson.JsonDeserializer;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject; | package org.ugeojson.parser.deserializer;
/**
* Deserializer for Feature
*
* @author moksuzer
*
*/
public class FeatureDeserializer implements JsonDeserializer<FeatureDto> {
@Override
public FeatureDto deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) {
FeatureDto dto = new FeatureDto();
JsonObject asJsonObject = json.getAsJsonObject();
JsonElement geometryElement = asJsonObject.get("geometry");
if (geometryElement != null) {
String typeOfGeometry = geometryElement.getAsJsonObject().get("type").getAsString();
GeoJSONObjectTypeEnum typeEnum = GeoJSONObjectTypeEnum.valueOf(typeOfGeometry);
GeometryDto geometryDto = context.deserialize(geometryElement, typeEnum.getDtoClass());
dto.setGeometry(geometryDto);
}
JsonElement propertiesJsonElement = asJsonObject.get("properties");
if (propertiesJsonElement != null) {
dto.setProperties(propertiesJsonElement.toString());
}
JsonElement idJsonElement = asJsonObject.get("id");
if (idJsonElement != null) {
dto.setId(idJsonElement.getAsString());
}
| // Path: ugeojson-model/src/main/java/org/ugeojson/model/GeoJSONObjectTypeEnum.java
// public enum GeoJSONObjectTypeEnum {
//
// Point(PointDto.class), MultiPoint(MultiPointDto.class), LineString(LineStringDto.class), MultiLineString(
// MultiLineStringDto.class), Polygon(PolygonDto.class), MultiPolygon(
// MultiPolygonDto.class), GeometryCollection(GeometryCollectionDto.class), Feature(
// FeatureDto.class), FeatureCollection(FeatureCollectionDto.class);
//
// private final Class dtoClass;
//
// private GeoJSONObjectTypeEnum(Class dtoClass) {
// this.dtoClass = dtoClass;
// }
//
// public Class getDtoClass() {
// return dtoClass;
// }
// }
//
// Path: ugeojson-model/src/main/java/org/ugeojson/model/feature/FeatureDto.java
// public class FeatureDto extends GeoJSONObjectDto {
//
// private static final long serialVersionUID = 1L;
//
// private GeometryDto geometry;
// private String properties;
// private String id;
//
// @Override
// public GeoJSONObjectTypeEnum getGeoJSONObjectType() {
// return GeoJSONObjectTypeEnum.Feature;
// }
//
// public GeometryDto getGeometry() {
// return geometry;
// }
//
// public void setGeometry(GeometryDto geometry) {
// this.geometry = geometry;
// }
//
// public String getProperties() {
// return properties;
// }
//
// public void setProperties(String properties) {
// this.properties = properties;
// }
//
// public String getId() {
// return id;
// }
//
// public void setId(String id) {
// this.id = id;
// }
//
// }
//
// Path: ugeojson-model/src/main/java/org/ugeojson/model/geometry/GeometryDto.java
// public abstract class GeometryDto extends GeoJSONObjectDto {
//
// private static final long serialVersionUID = 1L;
//
// }
//
// Path: ugeojson-parser/src/main/java/org/ugeojson/parser/util/BoundingBoxParser.java
// public class BoundingBoxParser {
//
// private static final int TWO_DIMENSIONAL_BBOX_LENGTH = 4;
//
// private BoundingBoxParser() {
// }
//
// public static BoundingBoxDto parseBbox(JsonObject asJsonObject, JsonDeserializationContext context) {
// BoundingBoxDto bboxDto = null;
// JsonElement bboxElement = asJsonObject.get("bbox");
// if (bboxElement != null) {
// double[] bbox = context.deserialize(bboxElement, double[].class);
// bboxDto = new BoundingBoxDto();
// if (bbox.length == TWO_DIMENSIONAL_BBOX_LENGTH) {
// bboxDto.setSouthWestCorner(new PositionDto(bbox[0], bbox[1]));
// bboxDto.setNorthEastCorner(new PositionDto(bbox[2], bbox[3]));
// } else {
// bboxDto.setSouthWestCorner(new PositionDto(bbox[0], bbox[1], bbox[2]));
// bboxDto.setNorthEastCorner(new PositionDto(bbox[3], bbox[4], bbox[5]));
// }
//
// }
// return bboxDto;
// }
//
// }
// Path: ugeojson-parser/src/main/java/org/ugeojson/parser/deserializer/FeatureDeserializer.java
import java.lang.reflect.Type;
import org.ugeojson.model.GeoJSONObjectTypeEnum;
import org.ugeojson.model.feature.FeatureDto;
import org.ugeojson.model.geometry.GeometryDto;
import org.ugeojson.parser.util.BoundingBoxParser;
import com.google.gson.JsonDeserializationContext;
import com.google.gson.JsonDeserializer;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
package org.ugeojson.parser.deserializer;
/**
* Deserializer for Feature
*
* @author moksuzer
*
*/
public class FeatureDeserializer implements JsonDeserializer<FeatureDto> {
@Override
public FeatureDto deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) {
FeatureDto dto = new FeatureDto();
JsonObject asJsonObject = json.getAsJsonObject();
JsonElement geometryElement = asJsonObject.get("geometry");
if (geometryElement != null) {
String typeOfGeometry = geometryElement.getAsJsonObject().get("type").getAsString();
GeoJSONObjectTypeEnum typeEnum = GeoJSONObjectTypeEnum.valueOf(typeOfGeometry);
GeometryDto geometryDto = context.deserialize(geometryElement, typeEnum.getDtoClass());
dto.setGeometry(geometryDto);
}
JsonElement propertiesJsonElement = asJsonObject.get("properties");
if (propertiesJsonElement != null) {
dto.setProperties(propertiesJsonElement.toString());
}
JsonElement idJsonElement = asJsonObject.get("id");
if (idJsonElement != null) {
dto.setId(idJsonElement.getAsString());
}
| dto.setBbox(BoundingBoxParser.parseBbox(asJsonObject, context)); |
mokszr/ultimate-geojson | ugeojson-parser/src/main/java/org/ugeojson/parser/deserializer/LineStringDeserializer.java | // Path: ugeojson-model/src/main/java/org/ugeojson/model/PositionDto.java
// public class PositionDto implements Serializable {
//
// private static final long serialVersionUID = 1L;
//
// private double[] numbers;
//
// /**
// * This constructor initializes numbers field to hold two double numbers. Do
// * not use this constructor if you need the third elevation parameter.
// */
// public PositionDto() {
// this.numbers = new double[2];
// }
//
// /**
// * Simple coordinate position constructor
// *
// * @param longitude
// * @param latitude
// */
// public PositionDto(double longitude, double latitude) {
// this.numbers = new double[] { longitude, latitude };
// }
//
// /**
// * Use this constructor if you need elevation parameter
// *
// * @param longitude
// * @param latitude
// * @param elevation
// */
// public PositionDto(double longitude, double latitude, double elevation) {
// this.numbers = new double[] { longitude, latitude, elevation };
// }
//
// /**
// * Copy constructor
// *
// * @param position
// */
// public PositionDto(PositionDto position) {
// if (position != null) {
// double[] copyNumbers = position.getNumbers();
// this.numbers = new double[copyNumbers.length];
// for (int i = 0; i < copyNumbers.length; i++) {
// this.numbers[i] = copyNumbers[i];
// }
// }
// }
//
// @Override
// public String toString() {
// if (numbers == null) {
// return "null numbers[]";
// }
// StringBuilder value = new StringBuilder("[");
// for (int i = 0; i < numbers.length; i++) {
// value.append(numbers[i]);
// if (i < numbers.length - 1) {
// value.append(", ");
// }
// }
// value.append("]");
// return value.toString();
// }
//
// public void setLongitude(double longitude) {
// this.numbers[0] = longitude;
// }
//
// public double getLongitude() {
// return numbers[0];
// }
//
// public void setLatitude(double latitude) {
// this.numbers[1] = latitude;
// }
//
// public double getLatitude() {
// return numbers[1];
// }
//
// public void setElevation(double elevation) {
// this.numbers[2] = elevation;
// }
//
// public double getElevation() {
// return numbers[2];
// }
//
// public double[] getNumbers() {
// return numbers;
// }
//
// public void setNumbers(double[] numbers) {
// this.numbers = numbers;
// }
// }
//
// Path: ugeojson-model/src/main/java/org/ugeojson/model/geometry/LineStringDto.java
// public class LineStringDto extends GeometryDto {
//
// private static final long serialVersionUID = 1L;
//
// private List<PositionDto> positions;
//
// public LineStringDto(){
// }
//
// public LineStringDto(List<PositionDto> positions){
// this.positions = new ArrayList<>();
// for (PositionDto positionDto : positions) {
// this.positions.add(new PositionDto(positionDto));
// }
// }
//
// public List<PositionDto> getPositions() {
// return positions;
// }
//
// public void setPositions(List<PositionDto> positions) {
// this.positions = positions;
// }
//
// @Override
// public GeoJSONObjectTypeEnum getGeoJSONObjectType() {
// return GeoJSONObjectTypeEnum.LineString;
// }
// }
//
// Path: ugeojson-parser/src/main/java/org/ugeojson/parser/util/BoundingBoxParser.java
// public class BoundingBoxParser {
//
// private static final int TWO_DIMENSIONAL_BBOX_LENGTH = 4;
//
// private BoundingBoxParser() {
// }
//
// public static BoundingBoxDto parseBbox(JsonObject asJsonObject, JsonDeserializationContext context) {
// BoundingBoxDto bboxDto = null;
// JsonElement bboxElement = asJsonObject.get("bbox");
// if (bboxElement != null) {
// double[] bbox = context.deserialize(bboxElement, double[].class);
// bboxDto = new BoundingBoxDto();
// if (bbox.length == TWO_DIMENSIONAL_BBOX_LENGTH) {
// bboxDto.setSouthWestCorner(new PositionDto(bbox[0], bbox[1]));
// bboxDto.setNorthEastCorner(new PositionDto(bbox[2], bbox[3]));
// } else {
// bboxDto.setSouthWestCorner(new PositionDto(bbox[0], bbox[1], bbox[2]));
// bboxDto.setNorthEastCorner(new PositionDto(bbox[3], bbox[4], bbox[5]));
// }
//
// }
// return bboxDto;
// }
//
// }
| import java.lang.reflect.Type;
import java.util.ArrayList;
import java.util.List;
import org.ugeojson.model.PositionDto;
import org.ugeojson.model.geometry.LineStringDto;
import org.ugeojson.parser.util.BoundingBoxParser;
import com.google.gson.JsonArray;
import com.google.gson.JsonDeserializationContext;
import com.google.gson.JsonDeserializer;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject; | package org.ugeojson.parser.deserializer;
/**
* Deserializer for LineString
*
* @author moksuzer
*
*/
public class LineStringDeserializer implements JsonDeserializer<LineStringDto> {
@Override
public LineStringDto deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) {
LineStringDto dto = new LineStringDto(); | // Path: ugeojson-model/src/main/java/org/ugeojson/model/PositionDto.java
// public class PositionDto implements Serializable {
//
// private static final long serialVersionUID = 1L;
//
// private double[] numbers;
//
// /**
// * This constructor initializes numbers field to hold two double numbers. Do
// * not use this constructor if you need the third elevation parameter.
// */
// public PositionDto() {
// this.numbers = new double[2];
// }
//
// /**
// * Simple coordinate position constructor
// *
// * @param longitude
// * @param latitude
// */
// public PositionDto(double longitude, double latitude) {
// this.numbers = new double[] { longitude, latitude };
// }
//
// /**
// * Use this constructor if you need elevation parameter
// *
// * @param longitude
// * @param latitude
// * @param elevation
// */
// public PositionDto(double longitude, double latitude, double elevation) {
// this.numbers = new double[] { longitude, latitude, elevation };
// }
//
// /**
// * Copy constructor
// *
// * @param position
// */
// public PositionDto(PositionDto position) {
// if (position != null) {
// double[] copyNumbers = position.getNumbers();
// this.numbers = new double[copyNumbers.length];
// for (int i = 0; i < copyNumbers.length; i++) {
// this.numbers[i] = copyNumbers[i];
// }
// }
// }
//
// @Override
// public String toString() {
// if (numbers == null) {
// return "null numbers[]";
// }
// StringBuilder value = new StringBuilder("[");
// for (int i = 0; i < numbers.length; i++) {
// value.append(numbers[i]);
// if (i < numbers.length - 1) {
// value.append(", ");
// }
// }
// value.append("]");
// return value.toString();
// }
//
// public void setLongitude(double longitude) {
// this.numbers[0] = longitude;
// }
//
// public double getLongitude() {
// return numbers[0];
// }
//
// public void setLatitude(double latitude) {
// this.numbers[1] = latitude;
// }
//
// public double getLatitude() {
// return numbers[1];
// }
//
// public void setElevation(double elevation) {
// this.numbers[2] = elevation;
// }
//
// public double getElevation() {
// return numbers[2];
// }
//
// public double[] getNumbers() {
// return numbers;
// }
//
// public void setNumbers(double[] numbers) {
// this.numbers = numbers;
// }
// }
//
// Path: ugeojson-model/src/main/java/org/ugeojson/model/geometry/LineStringDto.java
// public class LineStringDto extends GeometryDto {
//
// private static final long serialVersionUID = 1L;
//
// private List<PositionDto> positions;
//
// public LineStringDto(){
// }
//
// public LineStringDto(List<PositionDto> positions){
// this.positions = new ArrayList<>();
// for (PositionDto positionDto : positions) {
// this.positions.add(new PositionDto(positionDto));
// }
// }
//
// public List<PositionDto> getPositions() {
// return positions;
// }
//
// public void setPositions(List<PositionDto> positions) {
// this.positions = positions;
// }
//
// @Override
// public GeoJSONObjectTypeEnum getGeoJSONObjectType() {
// return GeoJSONObjectTypeEnum.LineString;
// }
// }
//
// Path: ugeojson-parser/src/main/java/org/ugeojson/parser/util/BoundingBoxParser.java
// public class BoundingBoxParser {
//
// private static final int TWO_DIMENSIONAL_BBOX_LENGTH = 4;
//
// private BoundingBoxParser() {
// }
//
// public static BoundingBoxDto parseBbox(JsonObject asJsonObject, JsonDeserializationContext context) {
// BoundingBoxDto bboxDto = null;
// JsonElement bboxElement = asJsonObject.get("bbox");
// if (bboxElement != null) {
// double[] bbox = context.deserialize(bboxElement, double[].class);
// bboxDto = new BoundingBoxDto();
// if (bbox.length == TWO_DIMENSIONAL_BBOX_LENGTH) {
// bboxDto.setSouthWestCorner(new PositionDto(bbox[0], bbox[1]));
// bboxDto.setNorthEastCorner(new PositionDto(bbox[2], bbox[3]));
// } else {
// bboxDto.setSouthWestCorner(new PositionDto(bbox[0], bbox[1], bbox[2]));
// bboxDto.setNorthEastCorner(new PositionDto(bbox[3], bbox[4], bbox[5]));
// }
//
// }
// return bboxDto;
// }
//
// }
// Path: ugeojson-parser/src/main/java/org/ugeojson/parser/deserializer/LineStringDeserializer.java
import java.lang.reflect.Type;
import java.util.ArrayList;
import java.util.List;
import org.ugeojson.model.PositionDto;
import org.ugeojson.model.geometry.LineStringDto;
import org.ugeojson.parser.util.BoundingBoxParser;
import com.google.gson.JsonArray;
import com.google.gson.JsonDeserializationContext;
import com.google.gson.JsonDeserializer;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
package org.ugeojson.parser.deserializer;
/**
* Deserializer for LineString
*
* @author moksuzer
*
*/
public class LineStringDeserializer implements JsonDeserializer<LineStringDto> {
@Override
public LineStringDto deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) {
LineStringDto dto = new LineStringDto(); | List<PositionDto> positions = new ArrayList<>(); |
mokszr/ultimate-geojson | ugeojson-builder/src/main/java/org/ugeojson/builder/geometry/PointBuilder.java | // Path: ugeojson-builder/src/main/java/org/ugeojson/builder/common/BuilderConstants.java
// public interface BuilderConstants {
//
// public static final String OPEN_BRACKET = "[";
// public static final String CLOSE_BRACKET = "]";
// public static final String OPEN_CURLY_BRACE = "{";
// public static final String CLOSE_CURLY_BRACE = "}";
//
// public static final String COMMA_SPACE = ", ";
// public static final String COMMA = ",";
// public static final String SPACE = " ";
// public static final String COMMA_NEWLINE = ",\n";
// public static final String NEWLINE = "\n";
// public static final String DOUBLE_QUOTE = "\"";
// public static final String NULL_VALUE = "null";
// public static final String TAB_SPACE = " ";
// public static final String EMPTY = "";
//
// public static final String TYPE_SPACE = "\"type\": ";
// public static final String COORDINATES_SPACE = "\"coordinates\": ";
// public static final String GEOMETRIES_SPACE = "\"geometries\": ";
// public static final String GEOMETRY_SPACE = "\"geometry\": ";
// public static final String PROPERTIES_SPACE = "\"properties\": ";
// public static final String ID_SPACE = "\"id\": ";
// public static final String FEATURES_SPACE = "\"features\": ";
// public static final String BBOX_SPACE = "\"bbox\": ";
// }
//
// Path: ugeojson-model/src/main/java/org/ugeojson/model/GeoJSONObjectTypeEnum.java
// public enum GeoJSONObjectTypeEnum {
//
// Point(PointDto.class), MultiPoint(MultiPointDto.class), LineString(LineStringDto.class), MultiLineString(
// MultiLineStringDto.class), Polygon(PolygonDto.class), MultiPolygon(
// MultiPolygonDto.class), GeometryCollection(GeometryCollectionDto.class), Feature(
// FeatureDto.class), FeatureCollection(FeatureCollectionDto.class);
//
// private final Class dtoClass;
//
// private GeoJSONObjectTypeEnum(Class dtoClass) {
// this.dtoClass = dtoClass;
// }
//
// public Class getDtoClass() {
// return dtoClass;
// }
// }
//
// Path: ugeojson-model/src/main/java/org/ugeojson/model/geometry/PointDto.java
// public class PointDto extends GeometryDto {
//
// private static final long serialVersionUID = 1L;
//
// private PositionDto position;
//
// /**
// * Creates two-dimensional position
// */
// public PointDto() {
// this.position = new PositionDto();
// }
//
// /**
// * Creates two-dimensional position with given longitude and latitude
// *
// * @param longitude
// * @param latitude
// */
// public PointDto(double longitude, double latitude) {
// this.position = new PositionDto(longitude, latitude);
// }
//
// /**
// * Creates three-dimensional position with given longitude, latitude and
// * elevation
// *
// * @param longitude
// * @param latitude
// * @param elevation
// */
// public PointDto(double longitude, double latitude, double elevation) {
// this.position = new PositionDto(longitude, latitude, elevation);
// }
//
// /**
// * Creates point with position parameters of given point
// *
// * @param point
// */
// public PointDto(PointDto point) {
// this.position = new PositionDto(point.getPosition());
// }
//
// /**
// * @param position
// */
// public PointDto(PositionDto position) {
// this.position = new PositionDto(position);
// }
//
// public double getLongitude() {
// return this.position.getLongitude();
// }
//
// public void setLongitude(double longitude) {
// this.position.setLongitude(longitude);
// }
//
// public double getLatitude() {
// return this.position.getLatitude();
// }
//
// public void setLatitude(double latitude) {
// this.position.setLatitude(latitude);
// }
//
// public void setElevation(double elevation) {
// this.position.setElevation(elevation);
// }
//
// public double getElevation() {
// return this.position.getElevation();
// }
//
// public PositionDto getPosition() {
// return position;
// }
//
// public void setPosition(PositionDto position) {
// this.position = position;
// }
//
// @Override
// public GeoJSONObjectTypeEnum getGeoJSONObjectType() {
// return GeoJSONObjectTypeEnum.Point;
// }
//
// }
| import org.ugeojson.builder.common.BuilderConstants;
import org.ugeojson.model.GeoJSONObjectTypeEnum;
import org.ugeojson.model.geometry.PointDto; | package org.ugeojson.builder.geometry;
/**
* @author moksuzer
*
*/
public class PointBuilder extends GeometryBuilder<PointDto> {
private static final PointBuilder INSTANCE = new PointBuilder();
public static PointBuilder getInstance() {
return INSTANCE;
}
private PointBuilder() {
}
/*
* (non-Javadoc)
*
* @see
* org.ugeojson.builder.geometry.GeometryBuilder#toGeometryGeoJSON(com
* .erumi.ugeojson.model.geometry.GeometryDto)
*/
@Override
public String toGeoJSON(PointDto point) {
if (point == null || point.getPosition() == null || point.getPosition().getNumbers().length == 0) { | // Path: ugeojson-builder/src/main/java/org/ugeojson/builder/common/BuilderConstants.java
// public interface BuilderConstants {
//
// public static final String OPEN_BRACKET = "[";
// public static final String CLOSE_BRACKET = "]";
// public static final String OPEN_CURLY_BRACE = "{";
// public static final String CLOSE_CURLY_BRACE = "}";
//
// public static final String COMMA_SPACE = ", ";
// public static final String COMMA = ",";
// public static final String SPACE = " ";
// public static final String COMMA_NEWLINE = ",\n";
// public static final String NEWLINE = "\n";
// public static final String DOUBLE_QUOTE = "\"";
// public static final String NULL_VALUE = "null";
// public static final String TAB_SPACE = " ";
// public static final String EMPTY = "";
//
// public static final String TYPE_SPACE = "\"type\": ";
// public static final String COORDINATES_SPACE = "\"coordinates\": ";
// public static final String GEOMETRIES_SPACE = "\"geometries\": ";
// public static final String GEOMETRY_SPACE = "\"geometry\": ";
// public static final String PROPERTIES_SPACE = "\"properties\": ";
// public static final String ID_SPACE = "\"id\": ";
// public static final String FEATURES_SPACE = "\"features\": ";
// public static final String BBOX_SPACE = "\"bbox\": ";
// }
//
// Path: ugeojson-model/src/main/java/org/ugeojson/model/GeoJSONObjectTypeEnum.java
// public enum GeoJSONObjectTypeEnum {
//
// Point(PointDto.class), MultiPoint(MultiPointDto.class), LineString(LineStringDto.class), MultiLineString(
// MultiLineStringDto.class), Polygon(PolygonDto.class), MultiPolygon(
// MultiPolygonDto.class), GeometryCollection(GeometryCollectionDto.class), Feature(
// FeatureDto.class), FeatureCollection(FeatureCollectionDto.class);
//
// private final Class dtoClass;
//
// private GeoJSONObjectTypeEnum(Class dtoClass) {
// this.dtoClass = dtoClass;
// }
//
// public Class getDtoClass() {
// return dtoClass;
// }
// }
//
// Path: ugeojson-model/src/main/java/org/ugeojson/model/geometry/PointDto.java
// public class PointDto extends GeometryDto {
//
// private static final long serialVersionUID = 1L;
//
// private PositionDto position;
//
// /**
// * Creates two-dimensional position
// */
// public PointDto() {
// this.position = new PositionDto();
// }
//
// /**
// * Creates two-dimensional position with given longitude and latitude
// *
// * @param longitude
// * @param latitude
// */
// public PointDto(double longitude, double latitude) {
// this.position = new PositionDto(longitude, latitude);
// }
//
// /**
// * Creates three-dimensional position with given longitude, latitude and
// * elevation
// *
// * @param longitude
// * @param latitude
// * @param elevation
// */
// public PointDto(double longitude, double latitude, double elevation) {
// this.position = new PositionDto(longitude, latitude, elevation);
// }
//
// /**
// * Creates point with position parameters of given point
// *
// * @param point
// */
// public PointDto(PointDto point) {
// this.position = new PositionDto(point.getPosition());
// }
//
// /**
// * @param position
// */
// public PointDto(PositionDto position) {
// this.position = new PositionDto(position);
// }
//
// public double getLongitude() {
// return this.position.getLongitude();
// }
//
// public void setLongitude(double longitude) {
// this.position.setLongitude(longitude);
// }
//
// public double getLatitude() {
// return this.position.getLatitude();
// }
//
// public void setLatitude(double latitude) {
// this.position.setLatitude(latitude);
// }
//
// public void setElevation(double elevation) {
// this.position.setElevation(elevation);
// }
//
// public double getElevation() {
// return this.position.getElevation();
// }
//
// public PositionDto getPosition() {
// return position;
// }
//
// public void setPosition(PositionDto position) {
// this.position = position;
// }
//
// @Override
// public GeoJSONObjectTypeEnum getGeoJSONObjectType() {
// return GeoJSONObjectTypeEnum.Point;
// }
//
// }
// Path: ugeojson-builder/src/main/java/org/ugeojson/builder/geometry/PointBuilder.java
import org.ugeojson.builder.common.BuilderConstants;
import org.ugeojson.model.GeoJSONObjectTypeEnum;
import org.ugeojson.model.geometry.PointDto;
package org.ugeojson.builder.geometry;
/**
* @author moksuzer
*
*/
public class PointBuilder extends GeometryBuilder<PointDto> {
private static final PointBuilder INSTANCE = new PointBuilder();
public static PointBuilder getInstance() {
return INSTANCE;
}
private PointBuilder() {
}
/*
* (non-Javadoc)
*
* @see
* org.ugeojson.builder.geometry.GeometryBuilder#toGeometryGeoJSON(com
* .erumi.ugeojson.model.geometry.GeometryDto)
*/
@Override
public String toGeoJSON(PointDto point) {
if (point == null || point.getPosition() == null || point.getPosition().getNumbers().length == 0) { | return BuilderConstants.NULL_VALUE; |
mokszr/ultimate-geojson | ugeojson-builder/src/main/java/org/ugeojson/builder/geometry/PointBuilder.java | // Path: ugeojson-builder/src/main/java/org/ugeojson/builder/common/BuilderConstants.java
// public interface BuilderConstants {
//
// public static final String OPEN_BRACKET = "[";
// public static final String CLOSE_BRACKET = "]";
// public static final String OPEN_CURLY_BRACE = "{";
// public static final String CLOSE_CURLY_BRACE = "}";
//
// public static final String COMMA_SPACE = ", ";
// public static final String COMMA = ",";
// public static final String SPACE = " ";
// public static final String COMMA_NEWLINE = ",\n";
// public static final String NEWLINE = "\n";
// public static final String DOUBLE_QUOTE = "\"";
// public static final String NULL_VALUE = "null";
// public static final String TAB_SPACE = " ";
// public static final String EMPTY = "";
//
// public static final String TYPE_SPACE = "\"type\": ";
// public static final String COORDINATES_SPACE = "\"coordinates\": ";
// public static final String GEOMETRIES_SPACE = "\"geometries\": ";
// public static final String GEOMETRY_SPACE = "\"geometry\": ";
// public static final String PROPERTIES_SPACE = "\"properties\": ";
// public static final String ID_SPACE = "\"id\": ";
// public static final String FEATURES_SPACE = "\"features\": ";
// public static final String BBOX_SPACE = "\"bbox\": ";
// }
//
// Path: ugeojson-model/src/main/java/org/ugeojson/model/GeoJSONObjectTypeEnum.java
// public enum GeoJSONObjectTypeEnum {
//
// Point(PointDto.class), MultiPoint(MultiPointDto.class), LineString(LineStringDto.class), MultiLineString(
// MultiLineStringDto.class), Polygon(PolygonDto.class), MultiPolygon(
// MultiPolygonDto.class), GeometryCollection(GeometryCollectionDto.class), Feature(
// FeatureDto.class), FeatureCollection(FeatureCollectionDto.class);
//
// private final Class dtoClass;
//
// private GeoJSONObjectTypeEnum(Class dtoClass) {
// this.dtoClass = dtoClass;
// }
//
// public Class getDtoClass() {
// return dtoClass;
// }
// }
//
// Path: ugeojson-model/src/main/java/org/ugeojson/model/geometry/PointDto.java
// public class PointDto extends GeometryDto {
//
// private static final long serialVersionUID = 1L;
//
// private PositionDto position;
//
// /**
// * Creates two-dimensional position
// */
// public PointDto() {
// this.position = new PositionDto();
// }
//
// /**
// * Creates two-dimensional position with given longitude and latitude
// *
// * @param longitude
// * @param latitude
// */
// public PointDto(double longitude, double latitude) {
// this.position = new PositionDto(longitude, latitude);
// }
//
// /**
// * Creates three-dimensional position with given longitude, latitude and
// * elevation
// *
// * @param longitude
// * @param latitude
// * @param elevation
// */
// public PointDto(double longitude, double latitude, double elevation) {
// this.position = new PositionDto(longitude, latitude, elevation);
// }
//
// /**
// * Creates point with position parameters of given point
// *
// * @param point
// */
// public PointDto(PointDto point) {
// this.position = new PositionDto(point.getPosition());
// }
//
// /**
// * @param position
// */
// public PointDto(PositionDto position) {
// this.position = new PositionDto(position);
// }
//
// public double getLongitude() {
// return this.position.getLongitude();
// }
//
// public void setLongitude(double longitude) {
// this.position.setLongitude(longitude);
// }
//
// public double getLatitude() {
// return this.position.getLatitude();
// }
//
// public void setLatitude(double latitude) {
// this.position.setLatitude(latitude);
// }
//
// public void setElevation(double elevation) {
// this.position.setElevation(elevation);
// }
//
// public double getElevation() {
// return this.position.getElevation();
// }
//
// public PositionDto getPosition() {
// return position;
// }
//
// public void setPosition(PositionDto position) {
// this.position = position;
// }
//
// @Override
// public GeoJSONObjectTypeEnum getGeoJSONObjectType() {
// return GeoJSONObjectTypeEnum.Point;
// }
//
// }
| import org.ugeojson.builder.common.BuilderConstants;
import org.ugeojson.model.GeoJSONObjectTypeEnum;
import org.ugeojson.model.geometry.PointDto; | package org.ugeojson.builder.geometry;
/**
* @author moksuzer
*
*/
public class PointBuilder extends GeometryBuilder<PointDto> {
private static final PointBuilder INSTANCE = new PointBuilder();
public static PointBuilder getInstance() {
return INSTANCE;
}
private PointBuilder() {
}
/*
* (non-Javadoc)
*
* @see
* org.ugeojson.builder.geometry.GeometryBuilder#toGeometryGeoJSON(com
* .erumi.ugeojson.model.geometry.GeometryDto)
*/
@Override
public String toGeoJSON(PointDto point) {
if (point == null || point.getPosition() == null || point.getPosition().getNumbers().length == 0) {
return BuilderConstants.NULL_VALUE;
}
StringBuilder builder = initializeBuilder(); | // Path: ugeojson-builder/src/main/java/org/ugeojson/builder/common/BuilderConstants.java
// public interface BuilderConstants {
//
// public static final String OPEN_BRACKET = "[";
// public static final String CLOSE_BRACKET = "]";
// public static final String OPEN_CURLY_BRACE = "{";
// public static final String CLOSE_CURLY_BRACE = "}";
//
// public static final String COMMA_SPACE = ", ";
// public static final String COMMA = ",";
// public static final String SPACE = " ";
// public static final String COMMA_NEWLINE = ",\n";
// public static final String NEWLINE = "\n";
// public static final String DOUBLE_QUOTE = "\"";
// public static final String NULL_VALUE = "null";
// public static final String TAB_SPACE = " ";
// public static final String EMPTY = "";
//
// public static final String TYPE_SPACE = "\"type\": ";
// public static final String COORDINATES_SPACE = "\"coordinates\": ";
// public static final String GEOMETRIES_SPACE = "\"geometries\": ";
// public static final String GEOMETRY_SPACE = "\"geometry\": ";
// public static final String PROPERTIES_SPACE = "\"properties\": ";
// public static final String ID_SPACE = "\"id\": ";
// public static final String FEATURES_SPACE = "\"features\": ";
// public static final String BBOX_SPACE = "\"bbox\": ";
// }
//
// Path: ugeojson-model/src/main/java/org/ugeojson/model/GeoJSONObjectTypeEnum.java
// public enum GeoJSONObjectTypeEnum {
//
// Point(PointDto.class), MultiPoint(MultiPointDto.class), LineString(LineStringDto.class), MultiLineString(
// MultiLineStringDto.class), Polygon(PolygonDto.class), MultiPolygon(
// MultiPolygonDto.class), GeometryCollection(GeometryCollectionDto.class), Feature(
// FeatureDto.class), FeatureCollection(FeatureCollectionDto.class);
//
// private final Class dtoClass;
//
// private GeoJSONObjectTypeEnum(Class dtoClass) {
// this.dtoClass = dtoClass;
// }
//
// public Class getDtoClass() {
// return dtoClass;
// }
// }
//
// Path: ugeojson-model/src/main/java/org/ugeojson/model/geometry/PointDto.java
// public class PointDto extends GeometryDto {
//
// private static final long serialVersionUID = 1L;
//
// private PositionDto position;
//
// /**
// * Creates two-dimensional position
// */
// public PointDto() {
// this.position = new PositionDto();
// }
//
// /**
// * Creates two-dimensional position with given longitude and latitude
// *
// * @param longitude
// * @param latitude
// */
// public PointDto(double longitude, double latitude) {
// this.position = new PositionDto(longitude, latitude);
// }
//
// /**
// * Creates three-dimensional position with given longitude, latitude and
// * elevation
// *
// * @param longitude
// * @param latitude
// * @param elevation
// */
// public PointDto(double longitude, double latitude, double elevation) {
// this.position = new PositionDto(longitude, latitude, elevation);
// }
//
// /**
// * Creates point with position parameters of given point
// *
// * @param point
// */
// public PointDto(PointDto point) {
// this.position = new PositionDto(point.getPosition());
// }
//
// /**
// * @param position
// */
// public PointDto(PositionDto position) {
// this.position = new PositionDto(position);
// }
//
// public double getLongitude() {
// return this.position.getLongitude();
// }
//
// public void setLongitude(double longitude) {
// this.position.setLongitude(longitude);
// }
//
// public double getLatitude() {
// return this.position.getLatitude();
// }
//
// public void setLatitude(double latitude) {
// this.position.setLatitude(latitude);
// }
//
// public void setElevation(double elevation) {
// this.position.setElevation(elevation);
// }
//
// public double getElevation() {
// return this.position.getElevation();
// }
//
// public PositionDto getPosition() {
// return position;
// }
//
// public void setPosition(PositionDto position) {
// this.position = position;
// }
//
// @Override
// public GeoJSONObjectTypeEnum getGeoJSONObjectType() {
// return GeoJSONObjectTypeEnum.Point;
// }
//
// }
// Path: ugeojson-builder/src/main/java/org/ugeojson/builder/geometry/PointBuilder.java
import org.ugeojson.builder.common.BuilderConstants;
import org.ugeojson.model.GeoJSONObjectTypeEnum;
import org.ugeojson.model.geometry.PointDto;
package org.ugeojson.builder.geometry;
/**
* @author moksuzer
*
*/
public class PointBuilder extends GeometryBuilder<PointDto> {
private static final PointBuilder INSTANCE = new PointBuilder();
public static PointBuilder getInstance() {
return INSTANCE;
}
private PointBuilder() {
}
/*
* (non-Javadoc)
*
* @see
* org.ugeojson.builder.geometry.GeometryBuilder#toGeometryGeoJSON(com
* .erumi.ugeojson.model.geometry.GeometryDto)
*/
@Override
public String toGeoJSON(PointDto point) {
if (point == null || point.getPosition() == null || point.getPosition().getNumbers().length == 0) {
return BuilderConstants.NULL_VALUE;
}
StringBuilder builder = initializeBuilder(); | buildTypePart(builder, GeoJSONObjectTypeEnum.Point); |
mokszr/ultimate-geojson | ugeojson-model/src/main/java/org/ugeojson/model/geometry/MultiPointDto.java | // Path: ugeojson-model/src/main/java/org/ugeojson/model/GeoJSONObjectTypeEnum.java
// public enum GeoJSONObjectTypeEnum {
//
// Point(PointDto.class), MultiPoint(MultiPointDto.class), LineString(LineStringDto.class), MultiLineString(
// MultiLineStringDto.class), Polygon(PolygonDto.class), MultiPolygon(
// MultiPolygonDto.class), GeometryCollection(GeometryCollectionDto.class), Feature(
// FeatureDto.class), FeatureCollection(FeatureCollectionDto.class);
//
// private final Class dtoClass;
//
// private GeoJSONObjectTypeEnum(Class dtoClass) {
// this.dtoClass = dtoClass;
// }
//
// public Class getDtoClass() {
// return dtoClass;
// }
// }
//
// Path: ugeojson-model/src/main/java/org/ugeojson/model/PositionDto.java
// public class PositionDto implements Serializable {
//
// private static final long serialVersionUID = 1L;
//
// private double[] numbers;
//
// /**
// * This constructor initializes numbers field to hold two double numbers. Do
// * not use this constructor if you need the third elevation parameter.
// */
// public PositionDto() {
// this.numbers = new double[2];
// }
//
// /**
// * Simple coordinate position constructor
// *
// * @param longitude
// * @param latitude
// */
// public PositionDto(double longitude, double latitude) {
// this.numbers = new double[] { longitude, latitude };
// }
//
// /**
// * Use this constructor if you need elevation parameter
// *
// * @param longitude
// * @param latitude
// * @param elevation
// */
// public PositionDto(double longitude, double latitude, double elevation) {
// this.numbers = new double[] { longitude, latitude, elevation };
// }
//
// /**
// * Copy constructor
// *
// * @param position
// */
// public PositionDto(PositionDto position) {
// if (position != null) {
// double[] copyNumbers = position.getNumbers();
// this.numbers = new double[copyNumbers.length];
// for (int i = 0; i < copyNumbers.length; i++) {
// this.numbers[i] = copyNumbers[i];
// }
// }
// }
//
// @Override
// public String toString() {
// if (numbers == null) {
// return "null numbers[]";
// }
// StringBuilder value = new StringBuilder("[");
// for (int i = 0; i < numbers.length; i++) {
// value.append(numbers[i]);
// if (i < numbers.length - 1) {
// value.append(", ");
// }
// }
// value.append("]");
// return value.toString();
// }
//
// public void setLongitude(double longitude) {
// this.numbers[0] = longitude;
// }
//
// public double getLongitude() {
// return numbers[0];
// }
//
// public void setLatitude(double latitude) {
// this.numbers[1] = latitude;
// }
//
// public double getLatitude() {
// return numbers[1];
// }
//
// public void setElevation(double elevation) {
// this.numbers[2] = elevation;
// }
//
// public double getElevation() {
// return numbers[2];
// }
//
// public double[] getNumbers() {
// return numbers;
// }
//
// public void setNumbers(double[] numbers) {
// this.numbers = numbers;
// }
// }
| import java.util.List;
import org.ugeojson.model.GeoJSONObjectTypeEnum;
import org.ugeojson.model.PositionDto; | package org.ugeojson.model.geometry;
/**
* @author moksuzer
*
*/
public class MultiPointDto extends GeometryDto {
private static final long serialVersionUID = 1L;
| // Path: ugeojson-model/src/main/java/org/ugeojson/model/GeoJSONObjectTypeEnum.java
// public enum GeoJSONObjectTypeEnum {
//
// Point(PointDto.class), MultiPoint(MultiPointDto.class), LineString(LineStringDto.class), MultiLineString(
// MultiLineStringDto.class), Polygon(PolygonDto.class), MultiPolygon(
// MultiPolygonDto.class), GeometryCollection(GeometryCollectionDto.class), Feature(
// FeatureDto.class), FeatureCollection(FeatureCollectionDto.class);
//
// private final Class dtoClass;
//
// private GeoJSONObjectTypeEnum(Class dtoClass) {
// this.dtoClass = dtoClass;
// }
//
// public Class getDtoClass() {
// return dtoClass;
// }
// }
//
// Path: ugeojson-model/src/main/java/org/ugeojson/model/PositionDto.java
// public class PositionDto implements Serializable {
//
// private static final long serialVersionUID = 1L;
//
// private double[] numbers;
//
// /**
// * This constructor initializes numbers field to hold two double numbers. Do
// * not use this constructor if you need the third elevation parameter.
// */
// public PositionDto() {
// this.numbers = new double[2];
// }
//
// /**
// * Simple coordinate position constructor
// *
// * @param longitude
// * @param latitude
// */
// public PositionDto(double longitude, double latitude) {
// this.numbers = new double[] { longitude, latitude };
// }
//
// /**
// * Use this constructor if you need elevation parameter
// *
// * @param longitude
// * @param latitude
// * @param elevation
// */
// public PositionDto(double longitude, double latitude, double elevation) {
// this.numbers = new double[] { longitude, latitude, elevation };
// }
//
// /**
// * Copy constructor
// *
// * @param position
// */
// public PositionDto(PositionDto position) {
// if (position != null) {
// double[] copyNumbers = position.getNumbers();
// this.numbers = new double[copyNumbers.length];
// for (int i = 0; i < copyNumbers.length; i++) {
// this.numbers[i] = copyNumbers[i];
// }
// }
// }
//
// @Override
// public String toString() {
// if (numbers == null) {
// return "null numbers[]";
// }
// StringBuilder value = new StringBuilder("[");
// for (int i = 0; i < numbers.length; i++) {
// value.append(numbers[i]);
// if (i < numbers.length - 1) {
// value.append(", ");
// }
// }
// value.append("]");
// return value.toString();
// }
//
// public void setLongitude(double longitude) {
// this.numbers[0] = longitude;
// }
//
// public double getLongitude() {
// return numbers[0];
// }
//
// public void setLatitude(double latitude) {
// this.numbers[1] = latitude;
// }
//
// public double getLatitude() {
// return numbers[1];
// }
//
// public void setElevation(double elevation) {
// this.numbers[2] = elevation;
// }
//
// public double getElevation() {
// return numbers[2];
// }
//
// public double[] getNumbers() {
// return numbers;
// }
//
// public void setNumbers(double[] numbers) {
// this.numbers = numbers;
// }
// }
// Path: ugeojson-model/src/main/java/org/ugeojson/model/geometry/MultiPointDto.java
import java.util.List;
import org.ugeojson.model.GeoJSONObjectTypeEnum;
import org.ugeojson.model.PositionDto;
package org.ugeojson.model.geometry;
/**
* @author moksuzer
*
*/
public class MultiPointDto extends GeometryDto {
private static final long serialVersionUID = 1L;
| private List<PositionDto> positions; |
mokszr/ultimate-geojson | ugeojson-model/src/main/java/org/ugeojson/model/geometry/MultiPointDto.java | // Path: ugeojson-model/src/main/java/org/ugeojson/model/GeoJSONObjectTypeEnum.java
// public enum GeoJSONObjectTypeEnum {
//
// Point(PointDto.class), MultiPoint(MultiPointDto.class), LineString(LineStringDto.class), MultiLineString(
// MultiLineStringDto.class), Polygon(PolygonDto.class), MultiPolygon(
// MultiPolygonDto.class), GeometryCollection(GeometryCollectionDto.class), Feature(
// FeatureDto.class), FeatureCollection(FeatureCollectionDto.class);
//
// private final Class dtoClass;
//
// private GeoJSONObjectTypeEnum(Class dtoClass) {
// this.dtoClass = dtoClass;
// }
//
// public Class getDtoClass() {
// return dtoClass;
// }
// }
//
// Path: ugeojson-model/src/main/java/org/ugeojson/model/PositionDto.java
// public class PositionDto implements Serializable {
//
// private static final long serialVersionUID = 1L;
//
// private double[] numbers;
//
// /**
// * This constructor initializes numbers field to hold two double numbers. Do
// * not use this constructor if you need the third elevation parameter.
// */
// public PositionDto() {
// this.numbers = new double[2];
// }
//
// /**
// * Simple coordinate position constructor
// *
// * @param longitude
// * @param latitude
// */
// public PositionDto(double longitude, double latitude) {
// this.numbers = new double[] { longitude, latitude };
// }
//
// /**
// * Use this constructor if you need elevation parameter
// *
// * @param longitude
// * @param latitude
// * @param elevation
// */
// public PositionDto(double longitude, double latitude, double elevation) {
// this.numbers = new double[] { longitude, latitude, elevation };
// }
//
// /**
// * Copy constructor
// *
// * @param position
// */
// public PositionDto(PositionDto position) {
// if (position != null) {
// double[] copyNumbers = position.getNumbers();
// this.numbers = new double[copyNumbers.length];
// for (int i = 0; i < copyNumbers.length; i++) {
// this.numbers[i] = copyNumbers[i];
// }
// }
// }
//
// @Override
// public String toString() {
// if (numbers == null) {
// return "null numbers[]";
// }
// StringBuilder value = new StringBuilder("[");
// for (int i = 0; i < numbers.length; i++) {
// value.append(numbers[i]);
// if (i < numbers.length - 1) {
// value.append(", ");
// }
// }
// value.append("]");
// return value.toString();
// }
//
// public void setLongitude(double longitude) {
// this.numbers[0] = longitude;
// }
//
// public double getLongitude() {
// return numbers[0];
// }
//
// public void setLatitude(double latitude) {
// this.numbers[1] = latitude;
// }
//
// public double getLatitude() {
// return numbers[1];
// }
//
// public void setElevation(double elevation) {
// this.numbers[2] = elevation;
// }
//
// public double getElevation() {
// return numbers[2];
// }
//
// public double[] getNumbers() {
// return numbers;
// }
//
// public void setNumbers(double[] numbers) {
// this.numbers = numbers;
// }
// }
| import java.util.List;
import org.ugeojson.model.GeoJSONObjectTypeEnum;
import org.ugeojson.model.PositionDto; | package org.ugeojson.model.geometry;
/**
* @author moksuzer
*
*/
public class MultiPointDto extends GeometryDto {
private static final long serialVersionUID = 1L;
private List<PositionDto> positions;
public List<PositionDto> getPositions() {
return positions;
}
public void setPositions(List<PositionDto> positions) {
this.positions = positions;
}
@Override | // Path: ugeojson-model/src/main/java/org/ugeojson/model/GeoJSONObjectTypeEnum.java
// public enum GeoJSONObjectTypeEnum {
//
// Point(PointDto.class), MultiPoint(MultiPointDto.class), LineString(LineStringDto.class), MultiLineString(
// MultiLineStringDto.class), Polygon(PolygonDto.class), MultiPolygon(
// MultiPolygonDto.class), GeometryCollection(GeometryCollectionDto.class), Feature(
// FeatureDto.class), FeatureCollection(FeatureCollectionDto.class);
//
// private final Class dtoClass;
//
// private GeoJSONObjectTypeEnum(Class dtoClass) {
// this.dtoClass = dtoClass;
// }
//
// public Class getDtoClass() {
// return dtoClass;
// }
// }
//
// Path: ugeojson-model/src/main/java/org/ugeojson/model/PositionDto.java
// public class PositionDto implements Serializable {
//
// private static final long serialVersionUID = 1L;
//
// private double[] numbers;
//
// /**
// * This constructor initializes numbers field to hold two double numbers. Do
// * not use this constructor if you need the third elevation parameter.
// */
// public PositionDto() {
// this.numbers = new double[2];
// }
//
// /**
// * Simple coordinate position constructor
// *
// * @param longitude
// * @param latitude
// */
// public PositionDto(double longitude, double latitude) {
// this.numbers = new double[] { longitude, latitude };
// }
//
// /**
// * Use this constructor if you need elevation parameter
// *
// * @param longitude
// * @param latitude
// * @param elevation
// */
// public PositionDto(double longitude, double latitude, double elevation) {
// this.numbers = new double[] { longitude, latitude, elevation };
// }
//
// /**
// * Copy constructor
// *
// * @param position
// */
// public PositionDto(PositionDto position) {
// if (position != null) {
// double[] copyNumbers = position.getNumbers();
// this.numbers = new double[copyNumbers.length];
// for (int i = 0; i < copyNumbers.length; i++) {
// this.numbers[i] = copyNumbers[i];
// }
// }
// }
//
// @Override
// public String toString() {
// if (numbers == null) {
// return "null numbers[]";
// }
// StringBuilder value = new StringBuilder("[");
// for (int i = 0; i < numbers.length; i++) {
// value.append(numbers[i]);
// if (i < numbers.length - 1) {
// value.append(", ");
// }
// }
// value.append("]");
// return value.toString();
// }
//
// public void setLongitude(double longitude) {
// this.numbers[0] = longitude;
// }
//
// public double getLongitude() {
// return numbers[0];
// }
//
// public void setLatitude(double latitude) {
// this.numbers[1] = latitude;
// }
//
// public double getLatitude() {
// return numbers[1];
// }
//
// public void setElevation(double elevation) {
// this.numbers[2] = elevation;
// }
//
// public double getElevation() {
// return numbers[2];
// }
//
// public double[] getNumbers() {
// return numbers;
// }
//
// public void setNumbers(double[] numbers) {
// this.numbers = numbers;
// }
// }
// Path: ugeojson-model/src/main/java/org/ugeojson/model/geometry/MultiPointDto.java
import java.util.List;
import org.ugeojson.model.GeoJSONObjectTypeEnum;
import org.ugeojson.model.PositionDto;
package org.ugeojson.model.geometry;
/**
* @author moksuzer
*
*/
public class MultiPointDto extends GeometryDto {
private static final long serialVersionUID = 1L;
private List<PositionDto> positions;
public List<PositionDto> getPositions() {
return positions;
}
public void setPositions(List<PositionDto> positions) {
this.positions = positions;
}
@Override | public GeoJSONObjectTypeEnum getGeoJSONObjectType() { |
mokszr/ultimate-geojson | ugeojson-parser/src/main/java/org/ugeojson/parser/deserializer/FeatureCollectionDeserializer.java | // Path: ugeojson-model/src/main/java/org/ugeojson/model/feature/FeatureCollectionDto.java
// public class FeatureCollectionDto extends GeoJSONObjectDto {
//
// private static final long serialVersionUID = 1L;
//
// private List<FeatureDto> features;
//
// @Override
// public GeoJSONObjectTypeEnum getGeoJSONObjectType() {
// return GeoJSONObjectTypeEnum.FeatureCollection;
// }
//
// public List<FeatureDto> getFeatures() {
// return features;
// }
//
// public void setFeatures(List<FeatureDto> features) {
// this.features = features;
// }
//
// }
//
// Path: ugeojson-model/src/main/java/org/ugeojson/model/feature/FeatureDto.java
// public class FeatureDto extends GeoJSONObjectDto {
//
// private static final long serialVersionUID = 1L;
//
// private GeometryDto geometry;
// private String properties;
// private String id;
//
// @Override
// public GeoJSONObjectTypeEnum getGeoJSONObjectType() {
// return GeoJSONObjectTypeEnum.Feature;
// }
//
// public GeometryDto getGeometry() {
// return geometry;
// }
//
// public void setGeometry(GeometryDto geometry) {
// this.geometry = geometry;
// }
//
// public String getProperties() {
// return properties;
// }
//
// public void setProperties(String properties) {
// this.properties = properties;
// }
//
// public String getId() {
// return id;
// }
//
// public void setId(String id) {
// this.id = id;
// }
//
// }
//
// Path: ugeojson-parser/src/main/java/org/ugeojson/parser/util/BoundingBoxParser.java
// public class BoundingBoxParser {
//
// private static final int TWO_DIMENSIONAL_BBOX_LENGTH = 4;
//
// private BoundingBoxParser() {
// }
//
// public static BoundingBoxDto parseBbox(JsonObject asJsonObject, JsonDeserializationContext context) {
// BoundingBoxDto bboxDto = null;
// JsonElement bboxElement = asJsonObject.get("bbox");
// if (bboxElement != null) {
// double[] bbox = context.deserialize(bboxElement, double[].class);
// bboxDto = new BoundingBoxDto();
// if (bbox.length == TWO_DIMENSIONAL_BBOX_LENGTH) {
// bboxDto.setSouthWestCorner(new PositionDto(bbox[0], bbox[1]));
// bboxDto.setNorthEastCorner(new PositionDto(bbox[2], bbox[3]));
// } else {
// bboxDto.setSouthWestCorner(new PositionDto(bbox[0], bbox[1], bbox[2]));
// bboxDto.setNorthEastCorner(new PositionDto(bbox[3], bbox[4], bbox[5]));
// }
//
// }
// return bboxDto;
// }
//
// }
| import java.lang.reflect.Type;
import java.util.ArrayList;
import java.util.List;
import org.ugeojson.model.feature.FeatureCollectionDto;
import org.ugeojson.model.feature.FeatureDto;
import org.ugeojson.parser.util.BoundingBoxParser;
import com.google.gson.JsonArray;
import com.google.gson.JsonDeserializationContext;
import com.google.gson.JsonDeserializer;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject; | package org.ugeojson.parser.deserializer;
/**
* Deserializer for FeatureCollection
*
* @author moksuzer
*
*/
public class FeatureCollectionDeserializer implements JsonDeserializer<FeatureCollectionDto> {
@Override
public FeatureCollectionDto deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) {
FeatureCollectionDto dto = new FeatureCollectionDto(); | // Path: ugeojson-model/src/main/java/org/ugeojson/model/feature/FeatureCollectionDto.java
// public class FeatureCollectionDto extends GeoJSONObjectDto {
//
// private static final long serialVersionUID = 1L;
//
// private List<FeatureDto> features;
//
// @Override
// public GeoJSONObjectTypeEnum getGeoJSONObjectType() {
// return GeoJSONObjectTypeEnum.FeatureCollection;
// }
//
// public List<FeatureDto> getFeatures() {
// return features;
// }
//
// public void setFeatures(List<FeatureDto> features) {
// this.features = features;
// }
//
// }
//
// Path: ugeojson-model/src/main/java/org/ugeojson/model/feature/FeatureDto.java
// public class FeatureDto extends GeoJSONObjectDto {
//
// private static final long serialVersionUID = 1L;
//
// private GeometryDto geometry;
// private String properties;
// private String id;
//
// @Override
// public GeoJSONObjectTypeEnum getGeoJSONObjectType() {
// return GeoJSONObjectTypeEnum.Feature;
// }
//
// public GeometryDto getGeometry() {
// return geometry;
// }
//
// public void setGeometry(GeometryDto geometry) {
// this.geometry = geometry;
// }
//
// public String getProperties() {
// return properties;
// }
//
// public void setProperties(String properties) {
// this.properties = properties;
// }
//
// public String getId() {
// return id;
// }
//
// public void setId(String id) {
// this.id = id;
// }
//
// }
//
// Path: ugeojson-parser/src/main/java/org/ugeojson/parser/util/BoundingBoxParser.java
// public class BoundingBoxParser {
//
// private static final int TWO_DIMENSIONAL_BBOX_LENGTH = 4;
//
// private BoundingBoxParser() {
// }
//
// public static BoundingBoxDto parseBbox(JsonObject asJsonObject, JsonDeserializationContext context) {
// BoundingBoxDto bboxDto = null;
// JsonElement bboxElement = asJsonObject.get("bbox");
// if (bboxElement != null) {
// double[] bbox = context.deserialize(bboxElement, double[].class);
// bboxDto = new BoundingBoxDto();
// if (bbox.length == TWO_DIMENSIONAL_BBOX_LENGTH) {
// bboxDto.setSouthWestCorner(new PositionDto(bbox[0], bbox[1]));
// bboxDto.setNorthEastCorner(new PositionDto(bbox[2], bbox[3]));
// } else {
// bboxDto.setSouthWestCorner(new PositionDto(bbox[0], bbox[1], bbox[2]));
// bboxDto.setNorthEastCorner(new PositionDto(bbox[3], bbox[4], bbox[5]));
// }
//
// }
// return bboxDto;
// }
//
// }
// Path: ugeojson-parser/src/main/java/org/ugeojson/parser/deserializer/FeatureCollectionDeserializer.java
import java.lang.reflect.Type;
import java.util.ArrayList;
import java.util.List;
import org.ugeojson.model.feature.FeatureCollectionDto;
import org.ugeojson.model.feature.FeatureDto;
import org.ugeojson.parser.util.BoundingBoxParser;
import com.google.gson.JsonArray;
import com.google.gson.JsonDeserializationContext;
import com.google.gson.JsonDeserializer;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
package org.ugeojson.parser.deserializer;
/**
* Deserializer for FeatureCollection
*
* @author moksuzer
*
*/
public class FeatureCollectionDeserializer implements JsonDeserializer<FeatureCollectionDto> {
@Override
public FeatureCollectionDto deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) {
FeatureCollectionDto dto = new FeatureCollectionDto(); | List<FeatureDto> features = new ArrayList<>(); |
mokszr/ultimate-geojson | ugeojson-parser/src/main/java/org/ugeojson/parser/deserializer/FeatureCollectionDeserializer.java | // Path: ugeojson-model/src/main/java/org/ugeojson/model/feature/FeatureCollectionDto.java
// public class FeatureCollectionDto extends GeoJSONObjectDto {
//
// private static final long serialVersionUID = 1L;
//
// private List<FeatureDto> features;
//
// @Override
// public GeoJSONObjectTypeEnum getGeoJSONObjectType() {
// return GeoJSONObjectTypeEnum.FeatureCollection;
// }
//
// public List<FeatureDto> getFeatures() {
// return features;
// }
//
// public void setFeatures(List<FeatureDto> features) {
// this.features = features;
// }
//
// }
//
// Path: ugeojson-model/src/main/java/org/ugeojson/model/feature/FeatureDto.java
// public class FeatureDto extends GeoJSONObjectDto {
//
// private static final long serialVersionUID = 1L;
//
// private GeometryDto geometry;
// private String properties;
// private String id;
//
// @Override
// public GeoJSONObjectTypeEnum getGeoJSONObjectType() {
// return GeoJSONObjectTypeEnum.Feature;
// }
//
// public GeometryDto getGeometry() {
// return geometry;
// }
//
// public void setGeometry(GeometryDto geometry) {
// this.geometry = geometry;
// }
//
// public String getProperties() {
// return properties;
// }
//
// public void setProperties(String properties) {
// this.properties = properties;
// }
//
// public String getId() {
// return id;
// }
//
// public void setId(String id) {
// this.id = id;
// }
//
// }
//
// Path: ugeojson-parser/src/main/java/org/ugeojson/parser/util/BoundingBoxParser.java
// public class BoundingBoxParser {
//
// private static final int TWO_DIMENSIONAL_BBOX_LENGTH = 4;
//
// private BoundingBoxParser() {
// }
//
// public static BoundingBoxDto parseBbox(JsonObject asJsonObject, JsonDeserializationContext context) {
// BoundingBoxDto bboxDto = null;
// JsonElement bboxElement = asJsonObject.get("bbox");
// if (bboxElement != null) {
// double[] bbox = context.deserialize(bboxElement, double[].class);
// bboxDto = new BoundingBoxDto();
// if (bbox.length == TWO_DIMENSIONAL_BBOX_LENGTH) {
// bboxDto.setSouthWestCorner(new PositionDto(bbox[0], bbox[1]));
// bboxDto.setNorthEastCorner(new PositionDto(bbox[2], bbox[3]));
// } else {
// bboxDto.setSouthWestCorner(new PositionDto(bbox[0], bbox[1], bbox[2]));
// bboxDto.setNorthEastCorner(new PositionDto(bbox[3], bbox[4], bbox[5]));
// }
//
// }
// return bboxDto;
// }
//
// }
| import java.lang.reflect.Type;
import java.util.ArrayList;
import java.util.List;
import org.ugeojson.model.feature.FeatureCollectionDto;
import org.ugeojson.model.feature.FeatureDto;
import org.ugeojson.parser.util.BoundingBoxParser;
import com.google.gson.JsonArray;
import com.google.gson.JsonDeserializationContext;
import com.google.gson.JsonDeserializer;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject; | package org.ugeojson.parser.deserializer;
/**
* Deserializer for FeatureCollection
*
* @author moksuzer
*
*/
public class FeatureCollectionDeserializer implements JsonDeserializer<FeatureCollectionDto> {
@Override
public FeatureCollectionDto deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) {
FeatureCollectionDto dto = new FeatureCollectionDto();
List<FeatureDto> features = new ArrayList<>();
dto.setFeatures(features);
JsonObject asJsonObject = json.getAsJsonObject();
JsonArray jsonArray = asJsonObject.get("features").getAsJsonArray();
if (jsonArray == null) {
return dto;
}
for (int i = 0; i < jsonArray.size(); i++) {
JsonObject featureElement = jsonArray.get(i).getAsJsonObject();
FeatureDto geometryDto = context.deserialize(featureElement, FeatureDto.class);
features.add(geometryDto);
}
| // Path: ugeojson-model/src/main/java/org/ugeojson/model/feature/FeatureCollectionDto.java
// public class FeatureCollectionDto extends GeoJSONObjectDto {
//
// private static final long serialVersionUID = 1L;
//
// private List<FeatureDto> features;
//
// @Override
// public GeoJSONObjectTypeEnum getGeoJSONObjectType() {
// return GeoJSONObjectTypeEnum.FeatureCollection;
// }
//
// public List<FeatureDto> getFeatures() {
// return features;
// }
//
// public void setFeatures(List<FeatureDto> features) {
// this.features = features;
// }
//
// }
//
// Path: ugeojson-model/src/main/java/org/ugeojson/model/feature/FeatureDto.java
// public class FeatureDto extends GeoJSONObjectDto {
//
// private static final long serialVersionUID = 1L;
//
// private GeometryDto geometry;
// private String properties;
// private String id;
//
// @Override
// public GeoJSONObjectTypeEnum getGeoJSONObjectType() {
// return GeoJSONObjectTypeEnum.Feature;
// }
//
// public GeometryDto getGeometry() {
// return geometry;
// }
//
// public void setGeometry(GeometryDto geometry) {
// this.geometry = geometry;
// }
//
// public String getProperties() {
// return properties;
// }
//
// public void setProperties(String properties) {
// this.properties = properties;
// }
//
// public String getId() {
// return id;
// }
//
// public void setId(String id) {
// this.id = id;
// }
//
// }
//
// Path: ugeojson-parser/src/main/java/org/ugeojson/parser/util/BoundingBoxParser.java
// public class BoundingBoxParser {
//
// private static final int TWO_DIMENSIONAL_BBOX_LENGTH = 4;
//
// private BoundingBoxParser() {
// }
//
// public static BoundingBoxDto parseBbox(JsonObject asJsonObject, JsonDeserializationContext context) {
// BoundingBoxDto bboxDto = null;
// JsonElement bboxElement = asJsonObject.get("bbox");
// if (bboxElement != null) {
// double[] bbox = context.deserialize(bboxElement, double[].class);
// bboxDto = new BoundingBoxDto();
// if (bbox.length == TWO_DIMENSIONAL_BBOX_LENGTH) {
// bboxDto.setSouthWestCorner(new PositionDto(bbox[0], bbox[1]));
// bboxDto.setNorthEastCorner(new PositionDto(bbox[2], bbox[3]));
// } else {
// bboxDto.setSouthWestCorner(new PositionDto(bbox[0], bbox[1], bbox[2]));
// bboxDto.setNorthEastCorner(new PositionDto(bbox[3], bbox[4], bbox[5]));
// }
//
// }
// return bboxDto;
// }
//
// }
// Path: ugeojson-parser/src/main/java/org/ugeojson/parser/deserializer/FeatureCollectionDeserializer.java
import java.lang.reflect.Type;
import java.util.ArrayList;
import java.util.List;
import org.ugeojson.model.feature.FeatureCollectionDto;
import org.ugeojson.model.feature.FeatureDto;
import org.ugeojson.parser.util.BoundingBoxParser;
import com.google.gson.JsonArray;
import com.google.gson.JsonDeserializationContext;
import com.google.gson.JsonDeserializer;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
package org.ugeojson.parser.deserializer;
/**
* Deserializer for FeatureCollection
*
* @author moksuzer
*
*/
public class FeatureCollectionDeserializer implements JsonDeserializer<FeatureCollectionDto> {
@Override
public FeatureCollectionDto deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) {
FeatureCollectionDto dto = new FeatureCollectionDto();
List<FeatureDto> features = new ArrayList<>();
dto.setFeatures(features);
JsonObject asJsonObject = json.getAsJsonObject();
JsonArray jsonArray = asJsonObject.get("features").getAsJsonArray();
if (jsonArray == null) {
return dto;
}
for (int i = 0; i < jsonArray.size(); i++) {
JsonObject featureElement = jsonArray.get(i).getAsJsonObject();
FeatureDto geometryDto = context.deserialize(featureElement, FeatureDto.class);
features.add(geometryDto);
}
| dto.setBbox(BoundingBoxParser.parseBbox(asJsonObject, context)); |
mokszr/ultimate-geojson | ugeojson-builder/src/main/java/org/ugeojson/builder/geometry/PolygonBuilder.java | // Path: ugeojson-builder/src/main/java/org/ugeojson/builder/common/BuilderConstants.java
// public interface BuilderConstants {
//
// public static final String OPEN_BRACKET = "[";
// public static final String CLOSE_BRACKET = "]";
// public static final String OPEN_CURLY_BRACE = "{";
// public static final String CLOSE_CURLY_BRACE = "}";
//
// public static final String COMMA_SPACE = ", ";
// public static final String COMMA = ",";
// public static final String SPACE = " ";
// public static final String COMMA_NEWLINE = ",\n";
// public static final String NEWLINE = "\n";
// public static final String DOUBLE_QUOTE = "\"";
// public static final String NULL_VALUE = "null";
// public static final String TAB_SPACE = " ";
// public static final String EMPTY = "";
//
// public static final String TYPE_SPACE = "\"type\": ";
// public static final String COORDINATES_SPACE = "\"coordinates\": ";
// public static final String GEOMETRIES_SPACE = "\"geometries\": ";
// public static final String GEOMETRY_SPACE = "\"geometry\": ";
// public static final String PROPERTIES_SPACE = "\"properties\": ";
// public static final String ID_SPACE = "\"id\": ";
// public static final String FEATURES_SPACE = "\"features\": ";
// public static final String BBOX_SPACE = "\"bbox\": ";
// }
//
// Path: ugeojson-model/src/main/java/org/ugeojson/model/GeoJSONObjectTypeEnum.java
// public enum GeoJSONObjectTypeEnum {
//
// Point(PointDto.class), MultiPoint(MultiPointDto.class), LineString(LineStringDto.class), MultiLineString(
// MultiLineStringDto.class), Polygon(PolygonDto.class), MultiPolygon(
// MultiPolygonDto.class), GeometryCollection(GeometryCollectionDto.class), Feature(
// FeatureDto.class), FeatureCollection(FeatureCollectionDto.class);
//
// private final Class dtoClass;
//
// private GeoJSONObjectTypeEnum(Class dtoClass) {
// this.dtoClass = dtoClass;
// }
//
// public Class getDtoClass() {
// return dtoClass;
// }
// }
//
// Path: ugeojson-model/src/main/java/org/ugeojson/model/geometry/LineStringDto.java
// public class LineStringDto extends GeometryDto {
//
// private static final long serialVersionUID = 1L;
//
// private List<PositionDto> positions;
//
// public LineStringDto(){
// }
//
// public LineStringDto(List<PositionDto> positions){
// this.positions = new ArrayList<>();
// for (PositionDto positionDto : positions) {
// this.positions.add(new PositionDto(positionDto));
// }
// }
//
// public List<PositionDto> getPositions() {
// return positions;
// }
//
// public void setPositions(List<PositionDto> positions) {
// this.positions = positions;
// }
//
// @Override
// public GeoJSONObjectTypeEnum getGeoJSONObjectType() {
// return GeoJSONObjectTypeEnum.LineString;
// }
// }
//
// Path: ugeojson-model/src/main/java/org/ugeojson/model/geometry/PolygonDto.java
// public class PolygonDto extends GeometryDto {
//
// private static final long serialVersionUID = 1L;
//
// private List<LineStringDto> linearRings;
//
// @Override
// public GeoJSONObjectTypeEnum getGeoJSONObjectType() {
// return GeoJSONObjectTypeEnum.Polygon;
// }
//
// public List<LineStringDto> getLinearRings() {
// return linearRings;
// }
//
// public void setLinearRings(List<LineStringDto> linearRings) {
// this.linearRings = linearRings;
// }
//
// }
| import java.util.List;
import org.ugeojson.builder.common.BuilderConstants;
import org.ugeojson.model.GeoJSONObjectTypeEnum;
import org.ugeojson.model.geometry.LineStringDto;
import org.ugeojson.model.geometry.PolygonDto; | package org.ugeojson.builder.geometry;
/**
* @author moksuzer
*
*/
public class PolygonBuilder extends GeometryBuilder<PolygonDto> {
private static final PolygonBuilder INSTANCE = new PolygonBuilder();
public static PolygonBuilder getInstance() {
return INSTANCE;
}
private PolygonBuilder() {
}
/*
* (non-Javadoc)
*
* @see
* org.ugeojson.builder.geometry.GeometryBuilder#toGeometryGeoJSON(com
* .erumi.ugeojson.model.geometry.GeometryDto)
*/
@Override
public String toGeoJSON(PolygonDto polygon) {
if (polygon == null || polygon.getLinearRings() == null || polygon.getLinearRings().isEmpty()) { | // Path: ugeojson-builder/src/main/java/org/ugeojson/builder/common/BuilderConstants.java
// public interface BuilderConstants {
//
// public static final String OPEN_BRACKET = "[";
// public static final String CLOSE_BRACKET = "]";
// public static final String OPEN_CURLY_BRACE = "{";
// public static final String CLOSE_CURLY_BRACE = "}";
//
// public static final String COMMA_SPACE = ", ";
// public static final String COMMA = ",";
// public static final String SPACE = " ";
// public static final String COMMA_NEWLINE = ",\n";
// public static final String NEWLINE = "\n";
// public static final String DOUBLE_QUOTE = "\"";
// public static final String NULL_VALUE = "null";
// public static final String TAB_SPACE = " ";
// public static final String EMPTY = "";
//
// public static final String TYPE_SPACE = "\"type\": ";
// public static final String COORDINATES_SPACE = "\"coordinates\": ";
// public static final String GEOMETRIES_SPACE = "\"geometries\": ";
// public static final String GEOMETRY_SPACE = "\"geometry\": ";
// public static final String PROPERTIES_SPACE = "\"properties\": ";
// public static final String ID_SPACE = "\"id\": ";
// public static final String FEATURES_SPACE = "\"features\": ";
// public static final String BBOX_SPACE = "\"bbox\": ";
// }
//
// Path: ugeojson-model/src/main/java/org/ugeojson/model/GeoJSONObjectTypeEnum.java
// public enum GeoJSONObjectTypeEnum {
//
// Point(PointDto.class), MultiPoint(MultiPointDto.class), LineString(LineStringDto.class), MultiLineString(
// MultiLineStringDto.class), Polygon(PolygonDto.class), MultiPolygon(
// MultiPolygonDto.class), GeometryCollection(GeometryCollectionDto.class), Feature(
// FeatureDto.class), FeatureCollection(FeatureCollectionDto.class);
//
// private final Class dtoClass;
//
// private GeoJSONObjectTypeEnum(Class dtoClass) {
// this.dtoClass = dtoClass;
// }
//
// public Class getDtoClass() {
// return dtoClass;
// }
// }
//
// Path: ugeojson-model/src/main/java/org/ugeojson/model/geometry/LineStringDto.java
// public class LineStringDto extends GeometryDto {
//
// private static final long serialVersionUID = 1L;
//
// private List<PositionDto> positions;
//
// public LineStringDto(){
// }
//
// public LineStringDto(List<PositionDto> positions){
// this.positions = new ArrayList<>();
// for (PositionDto positionDto : positions) {
// this.positions.add(new PositionDto(positionDto));
// }
// }
//
// public List<PositionDto> getPositions() {
// return positions;
// }
//
// public void setPositions(List<PositionDto> positions) {
// this.positions = positions;
// }
//
// @Override
// public GeoJSONObjectTypeEnum getGeoJSONObjectType() {
// return GeoJSONObjectTypeEnum.LineString;
// }
// }
//
// Path: ugeojson-model/src/main/java/org/ugeojson/model/geometry/PolygonDto.java
// public class PolygonDto extends GeometryDto {
//
// private static final long serialVersionUID = 1L;
//
// private List<LineStringDto> linearRings;
//
// @Override
// public GeoJSONObjectTypeEnum getGeoJSONObjectType() {
// return GeoJSONObjectTypeEnum.Polygon;
// }
//
// public List<LineStringDto> getLinearRings() {
// return linearRings;
// }
//
// public void setLinearRings(List<LineStringDto> linearRings) {
// this.linearRings = linearRings;
// }
//
// }
// Path: ugeojson-builder/src/main/java/org/ugeojson/builder/geometry/PolygonBuilder.java
import java.util.List;
import org.ugeojson.builder.common.BuilderConstants;
import org.ugeojson.model.GeoJSONObjectTypeEnum;
import org.ugeojson.model.geometry.LineStringDto;
import org.ugeojson.model.geometry.PolygonDto;
package org.ugeojson.builder.geometry;
/**
* @author moksuzer
*
*/
public class PolygonBuilder extends GeometryBuilder<PolygonDto> {
private static final PolygonBuilder INSTANCE = new PolygonBuilder();
public static PolygonBuilder getInstance() {
return INSTANCE;
}
private PolygonBuilder() {
}
/*
* (non-Javadoc)
*
* @see
* org.ugeojson.builder.geometry.GeometryBuilder#toGeometryGeoJSON(com
* .erumi.ugeojson.model.geometry.GeometryDto)
*/
@Override
public String toGeoJSON(PolygonDto polygon) {
if (polygon == null || polygon.getLinearRings() == null || polygon.getLinearRings().isEmpty()) { | return BuilderConstants.NULL_VALUE; |
mokszr/ultimate-geojson | ugeojson-builder/src/main/java/org/ugeojson/builder/geometry/PolygonBuilder.java | // Path: ugeojson-builder/src/main/java/org/ugeojson/builder/common/BuilderConstants.java
// public interface BuilderConstants {
//
// public static final String OPEN_BRACKET = "[";
// public static final String CLOSE_BRACKET = "]";
// public static final String OPEN_CURLY_BRACE = "{";
// public static final String CLOSE_CURLY_BRACE = "}";
//
// public static final String COMMA_SPACE = ", ";
// public static final String COMMA = ",";
// public static final String SPACE = " ";
// public static final String COMMA_NEWLINE = ",\n";
// public static final String NEWLINE = "\n";
// public static final String DOUBLE_QUOTE = "\"";
// public static final String NULL_VALUE = "null";
// public static final String TAB_SPACE = " ";
// public static final String EMPTY = "";
//
// public static final String TYPE_SPACE = "\"type\": ";
// public static final String COORDINATES_SPACE = "\"coordinates\": ";
// public static final String GEOMETRIES_SPACE = "\"geometries\": ";
// public static final String GEOMETRY_SPACE = "\"geometry\": ";
// public static final String PROPERTIES_SPACE = "\"properties\": ";
// public static final String ID_SPACE = "\"id\": ";
// public static final String FEATURES_SPACE = "\"features\": ";
// public static final String BBOX_SPACE = "\"bbox\": ";
// }
//
// Path: ugeojson-model/src/main/java/org/ugeojson/model/GeoJSONObjectTypeEnum.java
// public enum GeoJSONObjectTypeEnum {
//
// Point(PointDto.class), MultiPoint(MultiPointDto.class), LineString(LineStringDto.class), MultiLineString(
// MultiLineStringDto.class), Polygon(PolygonDto.class), MultiPolygon(
// MultiPolygonDto.class), GeometryCollection(GeometryCollectionDto.class), Feature(
// FeatureDto.class), FeatureCollection(FeatureCollectionDto.class);
//
// private final Class dtoClass;
//
// private GeoJSONObjectTypeEnum(Class dtoClass) {
// this.dtoClass = dtoClass;
// }
//
// public Class getDtoClass() {
// return dtoClass;
// }
// }
//
// Path: ugeojson-model/src/main/java/org/ugeojson/model/geometry/LineStringDto.java
// public class LineStringDto extends GeometryDto {
//
// private static final long serialVersionUID = 1L;
//
// private List<PositionDto> positions;
//
// public LineStringDto(){
// }
//
// public LineStringDto(List<PositionDto> positions){
// this.positions = new ArrayList<>();
// for (PositionDto positionDto : positions) {
// this.positions.add(new PositionDto(positionDto));
// }
// }
//
// public List<PositionDto> getPositions() {
// return positions;
// }
//
// public void setPositions(List<PositionDto> positions) {
// this.positions = positions;
// }
//
// @Override
// public GeoJSONObjectTypeEnum getGeoJSONObjectType() {
// return GeoJSONObjectTypeEnum.LineString;
// }
// }
//
// Path: ugeojson-model/src/main/java/org/ugeojson/model/geometry/PolygonDto.java
// public class PolygonDto extends GeometryDto {
//
// private static final long serialVersionUID = 1L;
//
// private List<LineStringDto> linearRings;
//
// @Override
// public GeoJSONObjectTypeEnum getGeoJSONObjectType() {
// return GeoJSONObjectTypeEnum.Polygon;
// }
//
// public List<LineStringDto> getLinearRings() {
// return linearRings;
// }
//
// public void setLinearRings(List<LineStringDto> linearRings) {
// this.linearRings = linearRings;
// }
//
// }
| import java.util.List;
import org.ugeojson.builder.common.BuilderConstants;
import org.ugeojson.model.GeoJSONObjectTypeEnum;
import org.ugeojson.model.geometry.LineStringDto;
import org.ugeojson.model.geometry.PolygonDto; | package org.ugeojson.builder.geometry;
/**
* @author moksuzer
*
*/
public class PolygonBuilder extends GeometryBuilder<PolygonDto> {
private static final PolygonBuilder INSTANCE = new PolygonBuilder();
public static PolygonBuilder getInstance() {
return INSTANCE;
}
private PolygonBuilder() {
}
/*
* (non-Javadoc)
*
* @see
* org.ugeojson.builder.geometry.GeometryBuilder#toGeometryGeoJSON(com
* .erumi.ugeojson.model.geometry.GeometryDto)
*/
@Override
public String toGeoJSON(PolygonDto polygon) {
if (polygon == null || polygon.getLinearRings() == null || polygon.getLinearRings().isEmpty()) {
return BuilderConstants.NULL_VALUE;
}
checkAndCorrectLinearRing(polygon);
StringBuilder builder = initializeBuilder(); | // Path: ugeojson-builder/src/main/java/org/ugeojson/builder/common/BuilderConstants.java
// public interface BuilderConstants {
//
// public static final String OPEN_BRACKET = "[";
// public static final String CLOSE_BRACKET = "]";
// public static final String OPEN_CURLY_BRACE = "{";
// public static final String CLOSE_CURLY_BRACE = "}";
//
// public static final String COMMA_SPACE = ", ";
// public static final String COMMA = ",";
// public static final String SPACE = " ";
// public static final String COMMA_NEWLINE = ",\n";
// public static final String NEWLINE = "\n";
// public static final String DOUBLE_QUOTE = "\"";
// public static final String NULL_VALUE = "null";
// public static final String TAB_SPACE = " ";
// public static final String EMPTY = "";
//
// public static final String TYPE_SPACE = "\"type\": ";
// public static final String COORDINATES_SPACE = "\"coordinates\": ";
// public static final String GEOMETRIES_SPACE = "\"geometries\": ";
// public static final String GEOMETRY_SPACE = "\"geometry\": ";
// public static final String PROPERTIES_SPACE = "\"properties\": ";
// public static final String ID_SPACE = "\"id\": ";
// public static final String FEATURES_SPACE = "\"features\": ";
// public static final String BBOX_SPACE = "\"bbox\": ";
// }
//
// Path: ugeojson-model/src/main/java/org/ugeojson/model/GeoJSONObjectTypeEnum.java
// public enum GeoJSONObjectTypeEnum {
//
// Point(PointDto.class), MultiPoint(MultiPointDto.class), LineString(LineStringDto.class), MultiLineString(
// MultiLineStringDto.class), Polygon(PolygonDto.class), MultiPolygon(
// MultiPolygonDto.class), GeometryCollection(GeometryCollectionDto.class), Feature(
// FeatureDto.class), FeatureCollection(FeatureCollectionDto.class);
//
// private final Class dtoClass;
//
// private GeoJSONObjectTypeEnum(Class dtoClass) {
// this.dtoClass = dtoClass;
// }
//
// public Class getDtoClass() {
// return dtoClass;
// }
// }
//
// Path: ugeojson-model/src/main/java/org/ugeojson/model/geometry/LineStringDto.java
// public class LineStringDto extends GeometryDto {
//
// private static final long serialVersionUID = 1L;
//
// private List<PositionDto> positions;
//
// public LineStringDto(){
// }
//
// public LineStringDto(List<PositionDto> positions){
// this.positions = new ArrayList<>();
// for (PositionDto positionDto : positions) {
// this.positions.add(new PositionDto(positionDto));
// }
// }
//
// public List<PositionDto> getPositions() {
// return positions;
// }
//
// public void setPositions(List<PositionDto> positions) {
// this.positions = positions;
// }
//
// @Override
// public GeoJSONObjectTypeEnum getGeoJSONObjectType() {
// return GeoJSONObjectTypeEnum.LineString;
// }
// }
//
// Path: ugeojson-model/src/main/java/org/ugeojson/model/geometry/PolygonDto.java
// public class PolygonDto extends GeometryDto {
//
// private static final long serialVersionUID = 1L;
//
// private List<LineStringDto> linearRings;
//
// @Override
// public GeoJSONObjectTypeEnum getGeoJSONObjectType() {
// return GeoJSONObjectTypeEnum.Polygon;
// }
//
// public List<LineStringDto> getLinearRings() {
// return linearRings;
// }
//
// public void setLinearRings(List<LineStringDto> linearRings) {
// this.linearRings = linearRings;
// }
//
// }
// Path: ugeojson-builder/src/main/java/org/ugeojson/builder/geometry/PolygonBuilder.java
import java.util.List;
import org.ugeojson.builder.common.BuilderConstants;
import org.ugeojson.model.GeoJSONObjectTypeEnum;
import org.ugeojson.model.geometry.LineStringDto;
import org.ugeojson.model.geometry.PolygonDto;
package org.ugeojson.builder.geometry;
/**
* @author moksuzer
*
*/
public class PolygonBuilder extends GeometryBuilder<PolygonDto> {
private static final PolygonBuilder INSTANCE = new PolygonBuilder();
public static PolygonBuilder getInstance() {
return INSTANCE;
}
private PolygonBuilder() {
}
/*
* (non-Javadoc)
*
* @see
* org.ugeojson.builder.geometry.GeometryBuilder#toGeometryGeoJSON(com
* .erumi.ugeojson.model.geometry.GeometryDto)
*/
@Override
public String toGeoJSON(PolygonDto polygon) {
if (polygon == null || polygon.getLinearRings() == null || polygon.getLinearRings().isEmpty()) {
return BuilderConstants.NULL_VALUE;
}
checkAndCorrectLinearRing(polygon);
StringBuilder builder = initializeBuilder(); | buildTypePart(builder, GeoJSONObjectTypeEnum.Polygon); |
mokszr/ultimate-geojson | ugeojson-builder/src/main/java/org/ugeojson/builder/geometry/PolygonBuilder.java | // Path: ugeojson-builder/src/main/java/org/ugeojson/builder/common/BuilderConstants.java
// public interface BuilderConstants {
//
// public static final String OPEN_BRACKET = "[";
// public static final String CLOSE_BRACKET = "]";
// public static final String OPEN_CURLY_BRACE = "{";
// public static final String CLOSE_CURLY_BRACE = "}";
//
// public static final String COMMA_SPACE = ", ";
// public static final String COMMA = ",";
// public static final String SPACE = " ";
// public static final String COMMA_NEWLINE = ",\n";
// public static final String NEWLINE = "\n";
// public static final String DOUBLE_QUOTE = "\"";
// public static final String NULL_VALUE = "null";
// public static final String TAB_SPACE = " ";
// public static final String EMPTY = "";
//
// public static final String TYPE_SPACE = "\"type\": ";
// public static final String COORDINATES_SPACE = "\"coordinates\": ";
// public static final String GEOMETRIES_SPACE = "\"geometries\": ";
// public static final String GEOMETRY_SPACE = "\"geometry\": ";
// public static final String PROPERTIES_SPACE = "\"properties\": ";
// public static final String ID_SPACE = "\"id\": ";
// public static final String FEATURES_SPACE = "\"features\": ";
// public static final String BBOX_SPACE = "\"bbox\": ";
// }
//
// Path: ugeojson-model/src/main/java/org/ugeojson/model/GeoJSONObjectTypeEnum.java
// public enum GeoJSONObjectTypeEnum {
//
// Point(PointDto.class), MultiPoint(MultiPointDto.class), LineString(LineStringDto.class), MultiLineString(
// MultiLineStringDto.class), Polygon(PolygonDto.class), MultiPolygon(
// MultiPolygonDto.class), GeometryCollection(GeometryCollectionDto.class), Feature(
// FeatureDto.class), FeatureCollection(FeatureCollectionDto.class);
//
// private final Class dtoClass;
//
// private GeoJSONObjectTypeEnum(Class dtoClass) {
// this.dtoClass = dtoClass;
// }
//
// public Class getDtoClass() {
// return dtoClass;
// }
// }
//
// Path: ugeojson-model/src/main/java/org/ugeojson/model/geometry/LineStringDto.java
// public class LineStringDto extends GeometryDto {
//
// private static final long serialVersionUID = 1L;
//
// private List<PositionDto> positions;
//
// public LineStringDto(){
// }
//
// public LineStringDto(List<PositionDto> positions){
// this.positions = new ArrayList<>();
// for (PositionDto positionDto : positions) {
// this.positions.add(new PositionDto(positionDto));
// }
// }
//
// public List<PositionDto> getPositions() {
// return positions;
// }
//
// public void setPositions(List<PositionDto> positions) {
// this.positions = positions;
// }
//
// @Override
// public GeoJSONObjectTypeEnum getGeoJSONObjectType() {
// return GeoJSONObjectTypeEnum.LineString;
// }
// }
//
// Path: ugeojson-model/src/main/java/org/ugeojson/model/geometry/PolygonDto.java
// public class PolygonDto extends GeometryDto {
//
// private static final long serialVersionUID = 1L;
//
// private List<LineStringDto> linearRings;
//
// @Override
// public GeoJSONObjectTypeEnum getGeoJSONObjectType() {
// return GeoJSONObjectTypeEnum.Polygon;
// }
//
// public List<LineStringDto> getLinearRings() {
// return linearRings;
// }
//
// public void setLinearRings(List<LineStringDto> linearRings) {
// this.linearRings = linearRings;
// }
//
// }
| import java.util.List;
import org.ugeojson.builder.common.BuilderConstants;
import org.ugeojson.model.GeoJSONObjectTypeEnum;
import org.ugeojson.model.geometry.LineStringDto;
import org.ugeojson.model.geometry.PolygonDto; | package org.ugeojson.builder.geometry;
/**
* @author moksuzer
*
*/
public class PolygonBuilder extends GeometryBuilder<PolygonDto> {
private static final PolygonBuilder INSTANCE = new PolygonBuilder();
public static PolygonBuilder getInstance() {
return INSTANCE;
}
private PolygonBuilder() {
}
/*
* (non-Javadoc)
*
* @see
* org.ugeojson.builder.geometry.GeometryBuilder#toGeometryGeoJSON(com
* .erumi.ugeojson.model.geometry.GeometryDto)
*/
@Override
public String toGeoJSON(PolygonDto polygon) {
if (polygon == null || polygon.getLinearRings() == null || polygon.getLinearRings().isEmpty()) {
return BuilderConstants.NULL_VALUE;
}
checkAndCorrectLinearRing(polygon);
StringBuilder builder = initializeBuilder();
buildTypePart(builder, GeoJSONObjectTypeEnum.Polygon);
builder.append(BuilderConstants.COORDINATES_SPACE);
builder.append(BuilderConstants.OPEN_BRACKET);
builder.append(BuilderConstants.NEWLINE);
| // Path: ugeojson-builder/src/main/java/org/ugeojson/builder/common/BuilderConstants.java
// public interface BuilderConstants {
//
// public static final String OPEN_BRACKET = "[";
// public static final String CLOSE_BRACKET = "]";
// public static final String OPEN_CURLY_BRACE = "{";
// public static final String CLOSE_CURLY_BRACE = "}";
//
// public static final String COMMA_SPACE = ", ";
// public static final String COMMA = ",";
// public static final String SPACE = " ";
// public static final String COMMA_NEWLINE = ",\n";
// public static final String NEWLINE = "\n";
// public static final String DOUBLE_QUOTE = "\"";
// public static final String NULL_VALUE = "null";
// public static final String TAB_SPACE = " ";
// public static final String EMPTY = "";
//
// public static final String TYPE_SPACE = "\"type\": ";
// public static final String COORDINATES_SPACE = "\"coordinates\": ";
// public static final String GEOMETRIES_SPACE = "\"geometries\": ";
// public static final String GEOMETRY_SPACE = "\"geometry\": ";
// public static final String PROPERTIES_SPACE = "\"properties\": ";
// public static final String ID_SPACE = "\"id\": ";
// public static final String FEATURES_SPACE = "\"features\": ";
// public static final String BBOX_SPACE = "\"bbox\": ";
// }
//
// Path: ugeojson-model/src/main/java/org/ugeojson/model/GeoJSONObjectTypeEnum.java
// public enum GeoJSONObjectTypeEnum {
//
// Point(PointDto.class), MultiPoint(MultiPointDto.class), LineString(LineStringDto.class), MultiLineString(
// MultiLineStringDto.class), Polygon(PolygonDto.class), MultiPolygon(
// MultiPolygonDto.class), GeometryCollection(GeometryCollectionDto.class), Feature(
// FeatureDto.class), FeatureCollection(FeatureCollectionDto.class);
//
// private final Class dtoClass;
//
// private GeoJSONObjectTypeEnum(Class dtoClass) {
// this.dtoClass = dtoClass;
// }
//
// public Class getDtoClass() {
// return dtoClass;
// }
// }
//
// Path: ugeojson-model/src/main/java/org/ugeojson/model/geometry/LineStringDto.java
// public class LineStringDto extends GeometryDto {
//
// private static final long serialVersionUID = 1L;
//
// private List<PositionDto> positions;
//
// public LineStringDto(){
// }
//
// public LineStringDto(List<PositionDto> positions){
// this.positions = new ArrayList<>();
// for (PositionDto positionDto : positions) {
// this.positions.add(new PositionDto(positionDto));
// }
// }
//
// public List<PositionDto> getPositions() {
// return positions;
// }
//
// public void setPositions(List<PositionDto> positions) {
// this.positions = positions;
// }
//
// @Override
// public GeoJSONObjectTypeEnum getGeoJSONObjectType() {
// return GeoJSONObjectTypeEnum.LineString;
// }
// }
//
// Path: ugeojson-model/src/main/java/org/ugeojson/model/geometry/PolygonDto.java
// public class PolygonDto extends GeometryDto {
//
// private static final long serialVersionUID = 1L;
//
// private List<LineStringDto> linearRings;
//
// @Override
// public GeoJSONObjectTypeEnum getGeoJSONObjectType() {
// return GeoJSONObjectTypeEnum.Polygon;
// }
//
// public List<LineStringDto> getLinearRings() {
// return linearRings;
// }
//
// public void setLinearRings(List<LineStringDto> linearRings) {
// this.linearRings = linearRings;
// }
//
// }
// Path: ugeojson-builder/src/main/java/org/ugeojson/builder/geometry/PolygonBuilder.java
import java.util.List;
import org.ugeojson.builder.common.BuilderConstants;
import org.ugeojson.model.GeoJSONObjectTypeEnum;
import org.ugeojson.model.geometry.LineStringDto;
import org.ugeojson.model.geometry.PolygonDto;
package org.ugeojson.builder.geometry;
/**
* @author moksuzer
*
*/
public class PolygonBuilder extends GeometryBuilder<PolygonDto> {
private static final PolygonBuilder INSTANCE = new PolygonBuilder();
public static PolygonBuilder getInstance() {
return INSTANCE;
}
private PolygonBuilder() {
}
/*
* (non-Javadoc)
*
* @see
* org.ugeojson.builder.geometry.GeometryBuilder#toGeometryGeoJSON(com
* .erumi.ugeojson.model.geometry.GeometryDto)
*/
@Override
public String toGeoJSON(PolygonDto polygon) {
if (polygon == null || polygon.getLinearRings() == null || polygon.getLinearRings().isEmpty()) {
return BuilderConstants.NULL_VALUE;
}
checkAndCorrectLinearRing(polygon);
StringBuilder builder = initializeBuilder();
buildTypePart(builder, GeoJSONObjectTypeEnum.Polygon);
builder.append(BuilderConstants.COORDINATES_SPACE);
builder.append(BuilderConstants.OPEN_BRACKET);
builder.append(BuilderConstants.NEWLINE);
| List<LineStringDto> linearRings = polygon.getLinearRings(); |
mokszr/ultimate-geojson | ugeojson-model/src/main/java/org/ugeojson/model/geometry/LineStringDto.java | // Path: ugeojson-model/src/main/java/org/ugeojson/model/GeoJSONObjectTypeEnum.java
// public enum GeoJSONObjectTypeEnum {
//
// Point(PointDto.class), MultiPoint(MultiPointDto.class), LineString(LineStringDto.class), MultiLineString(
// MultiLineStringDto.class), Polygon(PolygonDto.class), MultiPolygon(
// MultiPolygonDto.class), GeometryCollection(GeometryCollectionDto.class), Feature(
// FeatureDto.class), FeatureCollection(FeatureCollectionDto.class);
//
// private final Class dtoClass;
//
// private GeoJSONObjectTypeEnum(Class dtoClass) {
// this.dtoClass = dtoClass;
// }
//
// public Class getDtoClass() {
// return dtoClass;
// }
// }
//
// Path: ugeojson-model/src/main/java/org/ugeojson/model/PositionDto.java
// public class PositionDto implements Serializable {
//
// private static final long serialVersionUID = 1L;
//
// private double[] numbers;
//
// /**
// * This constructor initializes numbers field to hold two double numbers. Do
// * not use this constructor if you need the third elevation parameter.
// */
// public PositionDto() {
// this.numbers = new double[2];
// }
//
// /**
// * Simple coordinate position constructor
// *
// * @param longitude
// * @param latitude
// */
// public PositionDto(double longitude, double latitude) {
// this.numbers = new double[] { longitude, latitude };
// }
//
// /**
// * Use this constructor if you need elevation parameter
// *
// * @param longitude
// * @param latitude
// * @param elevation
// */
// public PositionDto(double longitude, double latitude, double elevation) {
// this.numbers = new double[] { longitude, latitude, elevation };
// }
//
// /**
// * Copy constructor
// *
// * @param position
// */
// public PositionDto(PositionDto position) {
// if (position != null) {
// double[] copyNumbers = position.getNumbers();
// this.numbers = new double[copyNumbers.length];
// for (int i = 0; i < copyNumbers.length; i++) {
// this.numbers[i] = copyNumbers[i];
// }
// }
// }
//
// @Override
// public String toString() {
// if (numbers == null) {
// return "null numbers[]";
// }
// StringBuilder value = new StringBuilder("[");
// for (int i = 0; i < numbers.length; i++) {
// value.append(numbers[i]);
// if (i < numbers.length - 1) {
// value.append(", ");
// }
// }
// value.append("]");
// return value.toString();
// }
//
// public void setLongitude(double longitude) {
// this.numbers[0] = longitude;
// }
//
// public double getLongitude() {
// return numbers[0];
// }
//
// public void setLatitude(double latitude) {
// this.numbers[1] = latitude;
// }
//
// public double getLatitude() {
// return numbers[1];
// }
//
// public void setElevation(double elevation) {
// this.numbers[2] = elevation;
// }
//
// public double getElevation() {
// return numbers[2];
// }
//
// public double[] getNumbers() {
// return numbers;
// }
//
// public void setNumbers(double[] numbers) {
// this.numbers = numbers;
// }
// }
| import java.util.ArrayList;
import java.util.List;
import org.ugeojson.model.GeoJSONObjectTypeEnum;
import org.ugeojson.model.PositionDto; | package org.ugeojson.model.geometry;
/**
* @author moksuzer
*
*/
public class LineStringDto extends GeometryDto {
private static final long serialVersionUID = 1L;
| // Path: ugeojson-model/src/main/java/org/ugeojson/model/GeoJSONObjectTypeEnum.java
// public enum GeoJSONObjectTypeEnum {
//
// Point(PointDto.class), MultiPoint(MultiPointDto.class), LineString(LineStringDto.class), MultiLineString(
// MultiLineStringDto.class), Polygon(PolygonDto.class), MultiPolygon(
// MultiPolygonDto.class), GeometryCollection(GeometryCollectionDto.class), Feature(
// FeatureDto.class), FeatureCollection(FeatureCollectionDto.class);
//
// private final Class dtoClass;
//
// private GeoJSONObjectTypeEnum(Class dtoClass) {
// this.dtoClass = dtoClass;
// }
//
// public Class getDtoClass() {
// return dtoClass;
// }
// }
//
// Path: ugeojson-model/src/main/java/org/ugeojson/model/PositionDto.java
// public class PositionDto implements Serializable {
//
// private static final long serialVersionUID = 1L;
//
// private double[] numbers;
//
// /**
// * This constructor initializes numbers field to hold two double numbers. Do
// * not use this constructor if you need the third elevation parameter.
// */
// public PositionDto() {
// this.numbers = new double[2];
// }
//
// /**
// * Simple coordinate position constructor
// *
// * @param longitude
// * @param latitude
// */
// public PositionDto(double longitude, double latitude) {
// this.numbers = new double[] { longitude, latitude };
// }
//
// /**
// * Use this constructor if you need elevation parameter
// *
// * @param longitude
// * @param latitude
// * @param elevation
// */
// public PositionDto(double longitude, double latitude, double elevation) {
// this.numbers = new double[] { longitude, latitude, elevation };
// }
//
// /**
// * Copy constructor
// *
// * @param position
// */
// public PositionDto(PositionDto position) {
// if (position != null) {
// double[] copyNumbers = position.getNumbers();
// this.numbers = new double[copyNumbers.length];
// for (int i = 0; i < copyNumbers.length; i++) {
// this.numbers[i] = copyNumbers[i];
// }
// }
// }
//
// @Override
// public String toString() {
// if (numbers == null) {
// return "null numbers[]";
// }
// StringBuilder value = new StringBuilder("[");
// for (int i = 0; i < numbers.length; i++) {
// value.append(numbers[i]);
// if (i < numbers.length - 1) {
// value.append(", ");
// }
// }
// value.append("]");
// return value.toString();
// }
//
// public void setLongitude(double longitude) {
// this.numbers[0] = longitude;
// }
//
// public double getLongitude() {
// return numbers[0];
// }
//
// public void setLatitude(double latitude) {
// this.numbers[1] = latitude;
// }
//
// public double getLatitude() {
// return numbers[1];
// }
//
// public void setElevation(double elevation) {
// this.numbers[2] = elevation;
// }
//
// public double getElevation() {
// return numbers[2];
// }
//
// public double[] getNumbers() {
// return numbers;
// }
//
// public void setNumbers(double[] numbers) {
// this.numbers = numbers;
// }
// }
// Path: ugeojson-model/src/main/java/org/ugeojson/model/geometry/LineStringDto.java
import java.util.ArrayList;
import java.util.List;
import org.ugeojson.model.GeoJSONObjectTypeEnum;
import org.ugeojson.model.PositionDto;
package org.ugeojson.model.geometry;
/**
* @author moksuzer
*
*/
public class LineStringDto extends GeometryDto {
private static final long serialVersionUID = 1L;
| private List<PositionDto> positions; |
mokszr/ultimate-geojson | ugeojson-model/src/main/java/org/ugeojson/model/geometry/LineStringDto.java | // Path: ugeojson-model/src/main/java/org/ugeojson/model/GeoJSONObjectTypeEnum.java
// public enum GeoJSONObjectTypeEnum {
//
// Point(PointDto.class), MultiPoint(MultiPointDto.class), LineString(LineStringDto.class), MultiLineString(
// MultiLineStringDto.class), Polygon(PolygonDto.class), MultiPolygon(
// MultiPolygonDto.class), GeometryCollection(GeometryCollectionDto.class), Feature(
// FeatureDto.class), FeatureCollection(FeatureCollectionDto.class);
//
// private final Class dtoClass;
//
// private GeoJSONObjectTypeEnum(Class dtoClass) {
// this.dtoClass = dtoClass;
// }
//
// public Class getDtoClass() {
// return dtoClass;
// }
// }
//
// Path: ugeojson-model/src/main/java/org/ugeojson/model/PositionDto.java
// public class PositionDto implements Serializable {
//
// private static final long serialVersionUID = 1L;
//
// private double[] numbers;
//
// /**
// * This constructor initializes numbers field to hold two double numbers. Do
// * not use this constructor if you need the third elevation parameter.
// */
// public PositionDto() {
// this.numbers = new double[2];
// }
//
// /**
// * Simple coordinate position constructor
// *
// * @param longitude
// * @param latitude
// */
// public PositionDto(double longitude, double latitude) {
// this.numbers = new double[] { longitude, latitude };
// }
//
// /**
// * Use this constructor if you need elevation parameter
// *
// * @param longitude
// * @param latitude
// * @param elevation
// */
// public PositionDto(double longitude, double latitude, double elevation) {
// this.numbers = new double[] { longitude, latitude, elevation };
// }
//
// /**
// * Copy constructor
// *
// * @param position
// */
// public PositionDto(PositionDto position) {
// if (position != null) {
// double[] copyNumbers = position.getNumbers();
// this.numbers = new double[copyNumbers.length];
// for (int i = 0; i < copyNumbers.length; i++) {
// this.numbers[i] = copyNumbers[i];
// }
// }
// }
//
// @Override
// public String toString() {
// if (numbers == null) {
// return "null numbers[]";
// }
// StringBuilder value = new StringBuilder("[");
// for (int i = 0; i < numbers.length; i++) {
// value.append(numbers[i]);
// if (i < numbers.length - 1) {
// value.append(", ");
// }
// }
// value.append("]");
// return value.toString();
// }
//
// public void setLongitude(double longitude) {
// this.numbers[0] = longitude;
// }
//
// public double getLongitude() {
// return numbers[0];
// }
//
// public void setLatitude(double latitude) {
// this.numbers[1] = latitude;
// }
//
// public double getLatitude() {
// return numbers[1];
// }
//
// public void setElevation(double elevation) {
// this.numbers[2] = elevation;
// }
//
// public double getElevation() {
// return numbers[2];
// }
//
// public double[] getNumbers() {
// return numbers;
// }
//
// public void setNumbers(double[] numbers) {
// this.numbers = numbers;
// }
// }
| import java.util.ArrayList;
import java.util.List;
import org.ugeojson.model.GeoJSONObjectTypeEnum;
import org.ugeojson.model.PositionDto; | package org.ugeojson.model.geometry;
/**
* @author moksuzer
*
*/
public class LineStringDto extends GeometryDto {
private static final long serialVersionUID = 1L;
private List<PositionDto> positions;
public LineStringDto(){
}
public LineStringDto(List<PositionDto> positions){
this.positions = new ArrayList<>();
for (PositionDto positionDto : positions) {
this.positions.add(new PositionDto(positionDto));
}
}
public List<PositionDto> getPositions() {
return positions;
}
public void setPositions(List<PositionDto> positions) {
this.positions = positions;
}
@Override | // Path: ugeojson-model/src/main/java/org/ugeojson/model/GeoJSONObjectTypeEnum.java
// public enum GeoJSONObjectTypeEnum {
//
// Point(PointDto.class), MultiPoint(MultiPointDto.class), LineString(LineStringDto.class), MultiLineString(
// MultiLineStringDto.class), Polygon(PolygonDto.class), MultiPolygon(
// MultiPolygonDto.class), GeometryCollection(GeometryCollectionDto.class), Feature(
// FeatureDto.class), FeatureCollection(FeatureCollectionDto.class);
//
// private final Class dtoClass;
//
// private GeoJSONObjectTypeEnum(Class dtoClass) {
// this.dtoClass = dtoClass;
// }
//
// public Class getDtoClass() {
// return dtoClass;
// }
// }
//
// Path: ugeojson-model/src/main/java/org/ugeojson/model/PositionDto.java
// public class PositionDto implements Serializable {
//
// private static final long serialVersionUID = 1L;
//
// private double[] numbers;
//
// /**
// * This constructor initializes numbers field to hold two double numbers. Do
// * not use this constructor if you need the third elevation parameter.
// */
// public PositionDto() {
// this.numbers = new double[2];
// }
//
// /**
// * Simple coordinate position constructor
// *
// * @param longitude
// * @param latitude
// */
// public PositionDto(double longitude, double latitude) {
// this.numbers = new double[] { longitude, latitude };
// }
//
// /**
// * Use this constructor if you need elevation parameter
// *
// * @param longitude
// * @param latitude
// * @param elevation
// */
// public PositionDto(double longitude, double latitude, double elevation) {
// this.numbers = new double[] { longitude, latitude, elevation };
// }
//
// /**
// * Copy constructor
// *
// * @param position
// */
// public PositionDto(PositionDto position) {
// if (position != null) {
// double[] copyNumbers = position.getNumbers();
// this.numbers = new double[copyNumbers.length];
// for (int i = 0; i < copyNumbers.length; i++) {
// this.numbers[i] = copyNumbers[i];
// }
// }
// }
//
// @Override
// public String toString() {
// if (numbers == null) {
// return "null numbers[]";
// }
// StringBuilder value = new StringBuilder("[");
// for (int i = 0; i < numbers.length; i++) {
// value.append(numbers[i]);
// if (i < numbers.length - 1) {
// value.append(", ");
// }
// }
// value.append("]");
// return value.toString();
// }
//
// public void setLongitude(double longitude) {
// this.numbers[0] = longitude;
// }
//
// public double getLongitude() {
// return numbers[0];
// }
//
// public void setLatitude(double latitude) {
// this.numbers[1] = latitude;
// }
//
// public double getLatitude() {
// return numbers[1];
// }
//
// public void setElevation(double elevation) {
// this.numbers[2] = elevation;
// }
//
// public double getElevation() {
// return numbers[2];
// }
//
// public double[] getNumbers() {
// return numbers;
// }
//
// public void setNumbers(double[] numbers) {
// this.numbers = numbers;
// }
// }
// Path: ugeojson-model/src/main/java/org/ugeojson/model/geometry/LineStringDto.java
import java.util.ArrayList;
import java.util.List;
import org.ugeojson.model.GeoJSONObjectTypeEnum;
import org.ugeojson.model.PositionDto;
package org.ugeojson.model.geometry;
/**
* @author moksuzer
*
*/
public class LineStringDto extends GeometryDto {
private static final long serialVersionUID = 1L;
private List<PositionDto> positions;
public LineStringDto(){
}
public LineStringDto(List<PositionDto> positions){
this.positions = new ArrayList<>();
for (PositionDto positionDto : positions) {
this.positions.add(new PositionDto(positionDto));
}
}
public List<PositionDto> getPositions() {
return positions;
}
public void setPositions(List<PositionDto> positions) {
this.positions = positions;
}
@Override | public GeoJSONObjectTypeEnum getGeoJSONObjectType() { |
mokszr/ultimate-geojson | ugeojson-model/src/main/java/org/ugeojson/model/feature/FeatureCollectionDto.java | // Path: ugeojson-model/src/main/java/org/ugeojson/model/GeoJSONObjectDto.java
// public abstract class GeoJSONObjectDto implements Serializable {
//
// private static final long serialVersionUID = 1L;
//
// private BoundingBoxDto bbox;
//
// public abstract GeoJSONObjectTypeEnum getGeoJSONObjectType();
//
// public BoundingBoxDto getBbox() {
// return bbox;
// }
//
// public void setBbox(BoundingBoxDto bbox) {
// this.bbox = bbox;
// }
// }
//
// Path: ugeojson-model/src/main/java/org/ugeojson/model/GeoJSONObjectTypeEnum.java
// public enum GeoJSONObjectTypeEnum {
//
// Point(PointDto.class), MultiPoint(MultiPointDto.class), LineString(LineStringDto.class), MultiLineString(
// MultiLineStringDto.class), Polygon(PolygonDto.class), MultiPolygon(
// MultiPolygonDto.class), GeometryCollection(GeometryCollectionDto.class), Feature(
// FeatureDto.class), FeatureCollection(FeatureCollectionDto.class);
//
// private final Class dtoClass;
//
// private GeoJSONObjectTypeEnum(Class dtoClass) {
// this.dtoClass = dtoClass;
// }
//
// public Class getDtoClass() {
// return dtoClass;
// }
// }
| import java.util.List;
import org.ugeojson.model.GeoJSONObjectDto;
import org.ugeojson.model.GeoJSONObjectTypeEnum; | package org.ugeojson.model.feature;
/**
* @author moksuzer
*
*/
public class FeatureCollectionDto extends GeoJSONObjectDto {
private static final long serialVersionUID = 1L;
private List<FeatureDto> features;
@Override | // Path: ugeojson-model/src/main/java/org/ugeojson/model/GeoJSONObjectDto.java
// public abstract class GeoJSONObjectDto implements Serializable {
//
// private static final long serialVersionUID = 1L;
//
// private BoundingBoxDto bbox;
//
// public abstract GeoJSONObjectTypeEnum getGeoJSONObjectType();
//
// public BoundingBoxDto getBbox() {
// return bbox;
// }
//
// public void setBbox(BoundingBoxDto bbox) {
// this.bbox = bbox;
// }
// }
//
// Path: ugeojson-model/src/main/java/org/ugeojson/model/GeoJSONObjectTypeEnum.java
// public enum GeoJSONObjectTypeEnum {
//
// Point(PointDto.class), MultiPoint(MultiPointDto.class), LineString(LineStringDto.class), MultiLineString(
// MultiLineStringDto.class), Polygon(PolygonDto.class), MultiPolygon(
// MultiPolygonDto.class), GeometryCollection(GeometryCollectionDto.class), Feature(
// FeatureDto.class), FeatureCollection(FeatureCollectionDto.class);
//
// private final Class dtoClass;
//
// private GeoJSONObjectTypeEnum(Class dtoClass) {
// this.dtoClass = dtoClass;
// }
//
// public Class getDtoClass() {
// return dtoClass;
// }
// }
// Path: ugeojson-model/src/main/java/org/ugeojson/model/feature/FeatureCollectionDto.java
import java.util.List;
import org.ugeojson.model.GeoJSONObjectDto;
import org.ugeojson.model.GeoJSONObjectTypeEnum;
package org.ugeojson.model.feature;
/**
* @author moksuzer
*
*/
public class FeatureCollectionDto extends GeoJSONObjectDto {
private static final long serialVersionUID = 1L;
private List<FeatureDto> features;
@Override | public GeoJSONObjectTypeEnum getGeoJSONObjectType() { |
mokszr/ultimate-geojson | ugeojson-builder/src/main/java/org/ugeojson/builder/geometry/PositionBuilder.java | // Path: ugeojson-builder/src/main/java/org/ugeojson/builder/common/BuilderConstants.java
// public interface BuilderConstants {
//
// public static final String OPEN_BRACKET = "[";
// public static final String CLOSE_BRACKET = "]";
// public static final String OPEN_CURLY_BRACE = "{";
// public static final String CLOSE_CURLY_BRACE = "}";
//
// public static final String COMMA_SPACE = ", ";
// public static final String COMMA = ",";
// public static final String SPACE = " ";
// public static final String COMMA_NEWLINE = ",\n";
// public static final String NEWLINE = "\n";
// public static final String DOUBLE_QUOTE = "\"";
// public static final String NULL_VALUE = "null";
// public static final String TAB_SPACE = " ";
// public static final String EMPTY = "";
//
// public static final String TYPE_SPACE = "\"type\": ";
// public static final String COORDINATES_SPACE = "\"coordinates\": ";
// public static final String GEOMETRIES_SPACE = "\"geometries\": ";
// public static final String GEOMETRY_SPACE = "\"geometry\": ";
// public static final String PROPERTIES_SPACE = "\"properties\": ";
// public static final String ID_SPACE = "\"id\": ";
// public static final String FEATURES_SPACE = "\"features\": ";
// public static final String BBOX_SPACE = "\"bbox\": ";
// }
//
// Path: ugeojson-builder/src/main/java/org/ugeojson/builder/exception/InvalidPositionDtoException.java
// public class InvalidPositionDtoException extends RuntimeException {
//
// private static final long serialVersionUID = 1L;
//
// public InvalidPositionDtoException(PositionDto position) {
// super("Invalid position dto: " + position);
// }
//
// }
//
// Path: ugeojson-model/src/main/java/org/ugeojson/model/PositionDto.java
// public class PositionDto implements Serializable {
//
// private static final long serialVersionUID = 1L;
//
// private double[] numbers;
//
// /**
// * This constructor initializes numbers field to hold two double numbers. Do
// * not use this constructor if you need the third elevation parameter.
// */
// public PositionDto() {
// this.numbers = new double[2];
// }
//
// /**
// * Simple coordinate position constructor
// *
// * @param longitude
// * @param latitude
// */
// public PositionDto(double longitude, double latitude) {
// this.numbers = new double[] { longitude, latitude };
// }
//
// /**
// * Use this constructor if you need elevation parameter
// *
// * @param longitude
// * @param latitude
// * @param elevation
// */
// public PositionDto(double longitude, double latitude, double elevation) {
// this.numbers = new double[] { longitude, latitude, elevation };
// }
//
// /**
// * Copy constructor
// *
// * @param position
// */
// public PositionDto(PositionDto position) {
// if (position != null) {
// double[] copyNumbers = position.getNumbers();
// this.numbers = new double[copyNumbers.length];
// for (int i = 0; i < copyNumbers.length; i++) {
// this.numbers[i] = copyNumbers[i];
// }
// }
// }
//
// @Override
// public String toString() {
// if (numbers == null) {
// return "null numbers[]";
// }
// StringBuilder value = new StringBuilder("[");
// for (int i = 0; i < numbers.length; i++) {
// value.append(numbers[i]);
// if (i < numbers.length - 1) {
// value.append(", ");
// }
// }
// value.append("]");
// return value.toString();
// }
//
// public void setLongitude(double longitude) {
// this.numbers[0] = longitude;
// }
//
// public double getLongitude() {
// return numbers[0];
// }
//
// public void setLatitude(double latitude) {
// this.numbers[1] = latitude;
// }
//
// public double getLatitude() {
// return numbers[1];
// }
//
// public void setElevation(double elevation) {
// this.numbers[2] = elevation;
// }
//
// public double getElevation() {
// return numbers[2];
// }
//
// public double[] getNumbers() {
// return numbers;
// }
//
// public void setNumbers(double[] numbers) {
// this.numbers = numbers;
// }
// }
| import org.ugeojson.builder.common.BuilderConstants;
import org.ugeojson.builder.exception.InvalidPositionDtoException;
import org.ugeojson.model.PositionDto; | package org.ugeojson.builder.geometry;
/**
* @author moksuzer
*
*/
public class PositionBuilder {
private static final int MINIMUM_POSITION_DIMENSION = 2;
private static final PositionBuilder INSTANCE = new PositionBuilder();
public static PositionBuilder getInstance(){
return INSTANCE;
}
private PositionBuilder(){
}
| // Path: ugeojson-builder/src/main/java/org/ugeojson/builder/common/BuilderConstants.java
// public interface BuilderConstants {
//
// public static final String OPEN_BRACKET = "[";
// public static final String CLOSE_BRACKET = "]";
// public static final String OPEN_CURLY_BRACE = "{";
// public static final String CLOSE_CURLY_BRACE = "}";
//
// public static final String COMMA_SPACE = ", ";
// public static final String COMMA = ",";
// public static final String SPACE = " ";
// public static final String COMMA_NEWLINE = ",\n";
// public static final String NEWLINE = "\n";
// public static final String DOUBLE_QUOTE = "\"";
// public static final String NULL_VALUE = "null";
// public static final String TAB_SPACE = " ";
// public static final String EMPTY = "";
//
// public static final String TYPE_SPACE = "\"type\": ";
// public static final String COORDINATES_SPACE = "\"coordinates\": ";
// public static final String GEOMETRIES_SPACE = "\"geometries\": ";
// public static final String GEOMETRY_SPACE = "\"geometry\": ";
// public static final String PROPERTIES_SPACE = "\"properties\": ";
// public static final String ID_SPACE = "\"id\": ";
// public static final String FEATURES_SPACE = "\"features\": ";
// public static final String BBOX_SPACE = "\"bbox\": ";
// }
//
// Path: ugeojson-builder/src/main/java/org/ugeojson/builder/exception/InvalidPositionDtoException.java
// public class InvalidPositionDtoException extends RuntimeException {
//
// private static final long serialVersionUID = 1L;
//
// public InvalidPositionDtoException(PositionDto position) {
// super("Invalid position dto: " + position);
// }
//
// }
//
// Path: ugeojson-model/src/main/java/org/ugeojson/model/PositionDto.java
// public class PositionDto implements Serializable {
//
// private static final long serialVersionUID = 1L;
//
// private double[] numbers;
//
// /**
// * This constructor initializes numbers field to hold two double numbers. Do
// * not use this constructor if you need the third elevation parameter.
// */
// public PositionDto() {
// this.numbers = new double[2];
// }
//
// /**
// * Simple coordinate position constructor
// *
// * @param longitude
// * @param latitude
// */
// public PositionDto(double longitude, double latitude) {
// this.numbers = new double[] { longitude, latitude };
// }
//
// /**
// * Use this constructor if you need elevation parameter
// *
// * @param longitude
// * @param latitude
// * @param elevation
// */
// public PositionDto(double longitude, double latitude, double elevation) {
// this.numbers = new double[] { longitude, latitude, elevation };
// }
//
// /**
// * Copy constructor
// *
// * @param position
// */
// public PositionDto(PositionDto position) {
// if (position != null) {
// double[] copyNumbers = position.getNumbers();
// this.numbers = new double[copyNumbers.length];
// for (int i = 0; i < copyNumbers.length; i++) {
// this.numbers[i] = copyNumbers[i];
// }
// }
// }
//
// @Override
// public String toString() {
// if (numbers == null) {
// return "null numbers[]";
// }
// StringBuilder value = new StringBuilder("[");
// for (int i = 0; i < numbers.length; i++) {
// value.append(numbers[i]);
// if (i < numbers.length - 1) {
// value.append(", ");
// }
// }
// value.append("]");
// return value.toString();
// }
//
// public void setLongitude(double longitude) {
// this.numbers[0] = longitude;
// }
//
// public double getLongitude() {
// return numbers[0];
// }
//
// public void setLatitude(double latitude) {
// this.numbers[1] = latitude;
// }
//
// public double getLatitude() {
// return numbers[1];
// }
//
// public void setElevation(double elevation) {
// this.numbers[2] = elevation;
// }
//
// public double getElevation() {
// return numbers[2];
// }
//
// public double[] getNumbers() {
// return numbers;
// }
//
// public void setNumbers(double[] numbers) {
// this.numbers = numbers;
// }
// }
// Path: ugeojson-builder/src/main/java/org/ugeojson/builder/geometry/PositionBuilder.java
import org.ugeojson.builder.common.BuilderConstants;
import org.ugeojson.builder.exception.InvalidPositionDtoException;
import org.ugeojson.model.PositionDto;
package org.ugeojson.builder.geometry;
/**
* @author moksuzer
*
*/
public class PositionBuilder {
private static final int MINIMUM_POSITION_DIMENSION = 2;
private static final PositionBuilder INSTANCE = new PositionBuilder();
public static PositionBuilder getInstance(){
return INSTANCE;
}
private PositionBuilder(){
}
| public String position(PositionDto position) { |
mokszr/ultimate-geojson | ugeojson-builder/src/main/java/org/ugeojson/builder/geometry/PositionBuilder.java | // Path: ugeojson-builder/src/main/java/org/ugeojson/builder/common/BuilderConstants.java
// public interface BuilderConstants {
//
// public static final String OPEN_BRACKET = "[";
// public static final String CLOSE_BRACKET = "]";
// public static final String OPEN_CURLY_BRACE = "{";
// public static final String CLOSE_CURLY_BRACE = "}";
//
// public static final String COMMA_SPACE = ", ";
// public static final String COMMA = ",";
// public static final String SPACE = " ";
// public static final String COMMA_NEWLINE = ",\n";
// public static final String NEWLINE = "\n";
// public static final String DOUBLE_QUOTE = "\"";
// public static final String NULL_VALUE = "null";
// public static final String TAB_SPACE = " ";
// public static final String EMPTY = "";
//
// public static final String TYPE_SPACE = "\"type\": ";
// public static final String COORDINATES_SPACE = "\"coordinates\": ";
// public static final String GEOMETRIES_SPACE = "\"geometries\": ";
// public static final String GEOMETRY_SPACE = "\"geometry\": ";
// public static final String PROPERTIES_SPACE = "\"properties\": ";
// public static final String ID_SPACE = "\"id\": ";
// public static final String FEATURES_SPACE = "\"features\": ";
// public static final String BBOX_SPACE = "\"bbox\": ";
// }
//
// Path: ugeojson-builder/src/main/java/org/ugeojson/builder/exception/InvalidPositionDtoException.java
// public class InvalidPositionDtoException extends RuntimeException {
//
// private static final long serialVersionUID = 1L;
//
// public InvalidPositionDtoException(PositionDto position) {
// super("Invalid position dto: " + position);
// }
//
// }
//
// Path: ugeojson-model/src/main/java/org/ugeojson/model/PositionDto.java
// public class PositionDto implements Serializable {
//
// private static final long serialVersionUID = 1L;
//
// private double[] numbers;
//
// /**
// * This constructor initializes numbers field to hold two double numbers. Do
// * not use this constructor if you need the third elevation parameter.
// */
// public PositionDto() {
// this.numbers = new double[2];
// }
//
// /**
// * Simple coordinate position constructor
// *
// * @param longitude
// * @param latitude
// */
// public PositionDto(double longitude, double latitude) {
// this.numbers = new double[] { longitude, latitude };
// }
//
// /**
// * Use this constructor if you need elevation parameter
// *
// * @param longitude
// * @param latitude
// * @param elevation
// */
// public PositionDto(double longitude, double latitude, double elevation) {
// this.numbers = new double[] { longitude, latitude, elevation };
// }
//
// /**
// * Copy constructor
// *
// * @param position
// */
// public PositionDto(PositionDto position) {
// if (position != null) {
// double[] copyNumbers = position.getNumbers();
// this.numbers = new double[copyNumbers.length];
// for (int i = 0; i < copyNumbers.length; i++) {
// this.numbers[i] = copyNumbers[i];
// }
// }
// }
//
// @Override
// public String toString() {
// if (numbers == null) {
// return "null numbers[]";
// }
// StringBuilder value = new StringBuilder("[");
// for (int i = 0; i < numbers.length; i++) {
// value.append(numbers[i]);
// if (i < numbers.length - 1) {
// value.append(", ");
// }
// }
// value.append("]");
// return value.toString();
// }
//
// public void setLongitude(double longitude) {
// this.numbers[0] = longitude;
// }
//
// public double getLongitude() {
// return numbers[0];
// }
//
// public void setLatitude(double latitude) {
// this.numbers[1] = latitude;
// }
//
// public double getLatitude() {
// return numbers[1];
// }
//
// public void setElevation(double elevation) {
// this.numbers[2] = elevation;
// }
//
// public double getElevation() {
// return numbers[2];
// }
//
// public double[] getNumbers() {
// return numbers;
// }
//
// public void setNumbers(double[] numbers) {
// this.numbers = numbers;
// }
// }
| import org.ugeojson.builder.common.BuilderConstants;
import org.ugeojson.builder.exception.InvalidPositionDtoException;
import org.ugeojson.model.PositionDto; | package org.ugeojson.builder.geometry;
/**
* @author moksuzer
*
*/
public class PositionBuilder {
private static final int MINIMUM_POSITION_DIMENSION = 2;
private static final PositionBuilder INSTANCE = new PositionBuilder();
public static PositionBuilder getInstance(){
return INSTANCE;
}
private PositionBuilder(){
}
public String position(PositionDto position) {
if(position == null || position.getNumbers().length < MINIMUM_POSITION_DIMENSION){ | // Path: ugeojson-builder/src/main/java/org/ugeojson/builder/common/BuilderConstants.java
// public interface BuilderConstants {
//
// public static final String OPEN_BRACKET = "[";
// public static final String CLOSE_BRACKET = "]";
// public static final String OPEN_CURLY_BRACE = "{";
// public static final String CLOSE_CURLY_BRACE = "}";
//
// public static final String COMMA_SPACE = ", ";
// public static final String COMMA = ",";
// public static final String SPACE = " ";
// public static final String COMMA_NEWLINE = ",\n";
// public static final String NEWLINE = "\n";
// public static final String DOUBLE_QUOTE = "\"";
// public static final String NULL_VALUE = "null";
// public static final String TAB_SPACE = " ";
// public static final String EMPTY = "";
//
// public static final String TYPE_SPACE = "\"type\": ";
// public static final String COORDINATES_SPACE = "\"coordinates\": ";
// public static final String GEOMETRIES_SPACE = "\"geometries\": ";
// public static final String GEOMETRY_SPACE = "\"geometry\": ";
// public static final String PROPERTIES_SPACE = "\"properties\": ";
// public static final String ID_SPACE = "\"id\": ";
// public static final String FEATURES_SPACE = "\"features\": ";
// public static final String BBOX_SPACE = "\"bbox\": ";
// }
//
// Path: ugeojson-builder/src/main/java/org/ugeojson/builder/exception/InvalidPositionDtoException.java
// public class InvalidPositionDtoException extends RuntimeException {
//
// private static final long serialVersionUID = 1L;
//
// public InvalidPositionDtoException(PositionDto position) {
// super("Invalid position dto: " + position);
// }
//
// }
//
// Path: ugeojson-model/src/main/java/org/ugeojson/model/PositionDto.java
// public class PositionDto implements Serializable {
//
// private static final long serialVersionUID = 1L;
//
// private double[] numbers;
//
// /**
// * This constructor initializes numbers field to hold two double numbers. Do
// * not use this constructor if you need the third elevation parameter.
// */
// public PositionDto() {
// this.numbers = new double[2];
// }
//
// /**
// * Simple coordinate position constructor
// *
// * @param longitude
// * @param latitude
// */
// public PositionDto(double longitude, double latitude) {
// this.numbers = new double[] { longitude, latitude };
// }
//
// /**
// * Use this constructor if you need elevation parameter
// *
// * @param longitude
// * @param latitude
// * @param elevation
// */
// public PositionDto(double longitude, double latitude, double elevation) {
// this.numbers = new double[] { longitude, latitude, elevation };
// }
//
// /**
// * Copy constructor
// *
// * @param position
// */
// public PositionDto(PositionDto position) {
// if (position != null) {
// double[] copyNumbers = position.getNumbers();
// this.numbers = new double[copyNumbers.length];
// for (int i = 0; i < copyNumbers.length; i++) {
// this.numbers[i] = copyNumbers[i];
// }
// }
// }
//
// @Override
// public String toString() {
// if (numbers == null) {
// return "null numbers[]";
// }
// StringBuilder value = new StringBuilder("[");
// for (int i = 0; i < numbers.length; i++) {
// value.append(numbers[i]);
// if (i < numbers.length - 1) {
// value.append(", ");
// }
// }
// value.append("]");
// return value.toString();
// }
//
// public void setLongitude(double longitude) {
// this.numbers[0] = longitude;
// }
//
// public double getLongitude() {
// return numbers[0];
// }
//
// public void setLatitude(double latitude) {
// this.numbers[1] = latitude;
// }
//
// public double getLatitude() {
// return numbers[1];
// }
//
// public void setElevation(double elevation) {
// this.numbers[2] = elevation;
// }
//
// public double getElevation() {
// return numbers[2];
// }
//
// public double[] getNumbers() {
// return numbers;
// }
//
// public void setNumbers(double[] numbers) {
// this.numbers = numbers;
// }
// }
// Path: ugeojson-builder/src/main/java/org/ugeojson/builder/geometry/PositionBuilder.java
import org.ugeojson.builder.common.BuilderConstants;
import org.ugeojson.builder.exception.InvalidPositionDtoException;
import org.ugeojson.model.PositionDto;
package org.ugeojson.builder.geometry;
/**
* @author moksuzer
*
*/
public class PositionBuilder {
private static final int MINIMUM_POSITION_DIMENSION = 2;
private static final PositionBuilder INSTANCE = new PositionBuilder();
public static PositionBuilder getInstance(){
return INSTANCE;
}
private PositionBuilder(){
}
public String position(PositionDto position) {
if(position == null || position.getNumbers().length < MINIMUM_POSITION_DIMENSION){ | throw new InvalidPositionDtoException(position); |
mokszr/ultimate-geojson | ugeojson-builder/src/main/java/org/ugeojson/builder/geometry/PositionBuilder.java | // Path: ugeojson-builder/src/main/java/org/ugeojson/builder/common/BuilderConstants.java
// public interface BuilderConstants {
//
// public static final String OPEN_BRACKET = "[";
// public static final String CLOSE_BRACKET = "]";
// public static final String OPEN_CURLY_BRACE = "{";
// public static final String CLOSE_CURLY_BRACE = "}";
//
// public static final String COMMA_SPACE = ", ";
// public static final String COMMA = ",";
// public static final String SPACE = " ";
// public static final String COMMA_NEWLINE = ",\n";
// public static final String NEWLINE = "\n";
// public static final String DOUBLE_QUOTE = "\"";
// public static final String NULL_VALUE = "null";
// public static final String TAB_SPACE = " ";
// public static final String EMPTY = "";
//
// public static final String TYPE_SPACE = "\"type\": ";
// public static final String COORDINATES_SPACE = "\"coordinates\": ";
// public static final String GEOMETRIES_SPACE = "\"geometries\": ";
// public static final String GEOMETRY_SPACE = "\"geometry\": ";
// public static final String PROPERTIES_SPACE = "\"properties\": ";
// public static final String ID_SPACE = "\"id\": ";
// public static final String FEATURES_SPACE = "\"features\": ";
// public static final String BBOX_SPACE = "\"bbox\": ";
// }
//
// Path: ugeojson-builder/src/main/java/org/ugeojson/builder/exception/InvalidPositionDtoException.java
// public class InvalidPositionDtoException extends RuntimeException {
//
// private static final long serialVersionUID = 1L;
//
// public InvalidPositionDtoException(PositionDto position) {
// super("Invalid position dto: " + position);
// }
//
// }
//
// Path: ugeojson-model/src/main/java/org/ugeojson/model/PositionDto.java
// public class PositionDto implements Serializable {
//
// private static final long serialVersionUID = 1L;
//
// private double[] numbers;
//
// /**
// * This constructor initializes numbers field to hold two double numbers. Do
// * not use this constructor if you need the third elevation parameter.
// */
// public PositionDto() {
// this.numbers = new double[2];
// }
//
// /**
// * Simple coordinate position constructor
// *
// * @param longitude
// * @param latitude
// */
// public PositionDto(double longitude, double latitude) {
// this.numbers = new double[] { longitude, latitude };
// }
//
// /**
// * Use this constructor if you need elevation parameter
// *
// * @param longitude
// * @param latitude
// * @param elevation
// */
// public PositionDto(double longitude, double latitude, double elevation) {
// this.numbers = new double[] { longitude, latitude, elevation };
// }
//
// /**
// * Copy constructor
// *
// * @param position
// */
// public PositionDto(PositionDto position) {
// if (position != null) {
// double[] copyNumbers = position.getNumbers();
// this.numbers = new double[copyNumbers.length];
// for (int i = 0; i < copyNumbers.length; i++) {
// this.numbers[i] = copyNumbers[i];
// }
// }
// }
//
// @Override
// public String toString() {
// if (numbers == null) {
// return "null numbers[]";
// }
// StringBuilder value = new StringBuilder("[");
// for (int i = 0; i < numbers.length; i++) {
// value.append(numbers[i]);
// if (i < numbers.length - 1) {
// value.append(", ");
// }
// }
// value.append("]");
// return value.toString();
// }
//
// public void setLongitude(double longitude) {
// this.numbers[0] = longitude;
// }
//
// public double getLongitude() {
// return numbers[0];
// }
//
// public void setLatitude(double latitude) {
// this.numbers[1] = latitude;
// }
//
// public double getLatitude() {
// return numbers[1];
// }
//
// public void setElevation(double elevation) {
// this.numbers[2] = elevation;
// }
//
// public double getElevation() {
// return numbers[2];
// }
//
// public double[] getNumbers() {
// return numbers;
// }
//
// public void setNumbers(double[] numbers) {
// this.numbers = numbers;
// }
// }
| import org.ugeojson.builder.common.BuilderConstants;
import org.ugeojson.builder.exception.InvalidPositionDtoException;
import org.ugeojson.model.PositionDto; | package org.ugeojson.builder.geometry;
/**
* @author moksuzer
*
*/
public class PositionBuilder {
private static final int MINIMUM_POSITION_DIMENSION = 2;
private static final PositionBuilder INSTANCE = new PositionBuilder();
public static PositionBuilder getInstance(){
return INSTANCE;
}
private PositionBuilder(){
}
public String position(PositionDto position) {
if(position == null || position.getNumbers().length < MINIMUM_POSITION_DIMENSION){
throw new InvalidPositionDtoException(position);
}
double[] numbers = position.getNumbers(); | // Path: ugeojson-builder/src/main/java/org/ugeojson/builder/common/BuilderConstants.java
// public interface BuilderConstants {
//
// public static final String OPEN_BRACKET = "[";
// public static final String CLOSE_BRACKET = "]";
// public static final String OPEN_CURLY_BRACE = "{";
// public static final String CLOSE_CURLY_BRACE = "}";
//
// public static final String COMMA_SPACE = ", ";
// public static final String COMMA = ",";
// public static final String SPACE = " ";
// public static final String COMMA_NEWLINE = ",\n";
// public static final String NEWLINE = "\n";
// public static final String DOUBLE_QUOTE = "\"";
// public static final String NULL_VALUE = "null";
// public static final String TAB_SPACE = " ";
// public static final String EMPTY = "";
//
// public static final String TYPE_SPACE = "\"type\": ";
// public static final String COORDINATES_SPACE = "\"coordinates\": ";
// public static final String GEOMETRIES_SPACE = "\"geometries\": ";
// public static final String GEOMETRY_SPACE = "\"geometry\": ";
// public static final String PROPERTIES_SPACE = "\"properties\": ";
// public static final String ID_SPACE = "\"id\": ";
// public static final String FEATURES_SPACE = "\"features\": ";
// public static final String BBOX_SPACE = "\"bbox\": ";
// }
//
// Path: ugeojson-builder/src/main/java/org/ugeojson/builder/exception/InvalidPositionDtoException.java
// public class InvalidPositionDtoException extends RuntimeException {
//
// private static final long serialVersionUID = 1L;
//
// public InvalidPositionDtoException(PositionDto position) {
// super("Invalid position dto: " + position);
// }
//
// }
//
// Path: ugeojson-model/src/main/java/org/ugeojson/model/PositionDto.java
// public class PositionDto implements Serializable {
//
// private static final long serialVersionUID = 1L;
//
// private double[] numbers;
//
// /**
// * This constructor initializes numbers field to hold two double numbers. Do
// * not use this constructor if you need the third elevation parameter.
// */
// public PositionDto() {
// this.numbers = new double[2];
// }
//
// /**
// * Simple coordinate position constructor
// *
// * @param longitude
// * @param latitude
// */
// public PositionDto(double longitude, double latitude) {
// this.numbers = new double[] { longitude, latitude };
// }
//
// /**
// * Use this constructor if you need elevation parameter
// *
// * @param longitude
// * @param latitude
// * @param elevation
// */
// public PositionDto(double longitude, double latitude, double elevation) {
// this.numbers = new double[] { longitude, latitude, elevation };
// }
//
// /**
// * Copy constructor
// *
// * @param position
// */
// public PositionDto(PositionDto position) {
// if (position != null) {
// double[] copyNumbers = position.getNumbers();
// this.numbers = new double[copyNumbers.length];
// for (int i = 0; i < copyNumbers.length; i++) {
// this.numbers[i] = copyNumbers[i];
// }
// }
// }
//
// @Override
// public String toString() {
// if (numbers == null) {
// return "null numbers[]";
// }
// StringBuilder value = new StringBuilder("[");
// for (int i = 0; i < numbers.length; i++) {
// value.append(numbers[i]);
// if (i < numbers.length - 1) {
// value.append(", ");
// }
// }
// value.append("]");
// return value.toString();
// }
//
// public void setLongitude(double longitude) {
// this.numbers[0] = longitude;
// }
//
// public double getLongitude() {
// return numbers[0];
// }
//
// public void setLatitude(double latitude) {
// this.numbers[1] = latitude;
// }
//
// public double getLatitude() {
// return numbers[1];
// }
//
// public void setElevation(double elevation) {
// this.numbers[2] = elevation;
// }
//
// public double getElevation() {
// return numbers[2];
// }
//
// public double[] getNumbers() {
// return numbers;
// }
//
// public void setNumbers(double[] numbers) {
// this.numbers = numbers;
// }
// }
// Path: ugeojson-builder/src/main/java/org/ugeojson/builder/geometry/PositionBuilder.java
import org.ugeojson.builder.common.BuilderConstants;
import org.ugeojson.builder.exception.InvalidPositionDtoException;
import org.ugeojson.model.PositionDto;
package org.ugeojson.builder.geometry;
/**
* @author moksuzer
*
*/
public class PositionBuilder {
private static final int MINIMUM_POSITION_DIMENSION = 2;
private static final PositionBuilder INSTANCE = new PositionBuilder();
public static PositionBuilder getInstance(){
return INSTANCE;
}
private PositionBuilder(){
}
public String position(PositionDto position) {
if(position == null || position.getNumbers().length < MINIMUM_POSITION_DIMENSION){
throw new InvalidPositionDtoException(position);
}
double[] numbers = position.getNumbers(); | StringBuilder builder = new StringBuilder(BuilderConstants.OPEN_BRACKET); |
mokszr/ultimate-geojson | ugeojson-model/src/main/java/org/ugeojson/model/geometry/MultiPolygonDto.java | // Path: ugeojson-model/src/main/java/org/ugeojson/model/GeoJSONObjectTypeEnum.java
// public enum GeoJSONObjectTypeEnum {
//
// Point(PointDto.class), MultiPoint(MultiPointDto.class), LineString(LineStringDto.class), MultiLineString(
// MultiLineStringDto.class), Polygon(PolygonDto.class), MultiPolygon(
// MultiPolygonDto.class), GeometryCollection(GeometryCollectionDto.class), Feature(
// FeatureDto.class), FeatureCollection(FeatureCollectionDto.class);
//
// private final Class dtoClass;
//
// private GeoJSONObjectTypeEnum(Class dtoClass) {
// this.dtoClass = dtoClass;
// }
//
// public Class getDtoClass() {
// return dtoClass;
// }
// }
| import java.util.List;
import org.ugeojson.model.GeoJSONObjectTypeEnum; | package org.ugeojson.model.geometry;
/**
* @author moksuzer
*
*/
public class MultiPolygonDto extends GeometryDto {
private static final long serialVersionUID = 1L;
private List<PolygonDto> polygons;
public List<PolygonDto> getPolygons() {
return polygons;
}
public void setPolygons(List<PolygonDto> polygons) {
this.polygons = polygons;
}
@Override | // Path: ugeojson-model/src/main/java/org/ugeojson/model/GeoJSONObjectTypeEnum.java
// public enum GeoJSONObjectTypeEnum {
//
// Point(PointDto.class), MultiPoint(MultiPointDto.class), LineString(LineStringDto.class), MultiLineString(
// MultiLineStringDto.class), Polygon(PolygonDto.class), MultiPolygon(
// MultiPolygonDto.class), GeometryCollection(GeometryCollectionDto.class), Feature(
// FeatureDto.class), FeatureCollection(FeatureCollectionDto.class);
//
// private final Class dtoClass;
//
// private GeoJSONObjectTypeEnum(Class dtoClass) {
// this.dtoClass = dtoClass;
// }
//
// public Class getDtoClass() {
// return dtoClass;
// }
// }
// Path: ugeojson-model/src/main/java/org/ugeojson/model/geometry/MultiPolygonDto.java
import java.util.List;
import org.ugeojson.model.GeoJSONObjectTypeEnum;
package org.ugeojson.model.geometry;
/**
* @author moksuzer
*
*/
public class MultiPolygonDto extends GeometryDto {
private static final long serialVersionUID = 1L;
private List<PolygonDto> polygons;
public List<PolygonDto> getPolygons() {
return polygons;
}
public void setPolygons(List<PolygonDto> polygons) {
this.polygons = polygons;
}
@Override | public GeoJSONObjectTypeEnum getGeoJSONObjectType() { |
mokszr/ultimate-geojson | ugeojson-builder/src/main/java/org/ugeojson/builder/geometry/GeometryCollectionBuilder.java | // Path: ugeojson-builder/src/main/java/org/ugeojson/builder/common/BuilderConstants.java
// public interface BuilderConstants {
//
// public static final String OPEN_BRACKET = "[";
// public static final String CLOSE_BRACKET = "]";
// public static final String OPEN_CURLY_BRACE = "{";
// public static final String CLOSE_CURLY_BRACE = "}";
//
// public static final String COMMA_SPACE = ", ";
// public static final String COMMA = ",";
// public static final String SPACE = " ";
// public static final String COMMA_NEWLINE = ",\n";
// public static final String NEWLINE = "\n";
// public static final String DOUBLE_QUOTE = "\"";
// public static final String NULL_VALUE = "null";
// public static final String TAB_SPACE = " ";
// public static final String EMPTY = "";
//
// public static final String TYPE_SPACE = "\"type\": ";
// public static final String COORDINATES_SPACE = "\"coordinates\": ";
// public static final String GEOMETRIES_SPACE = "\"geometries\": ";
// public static final String GEOMETRY_SPACE = "\"geometry\": ";
// public static final String PROPERTIES_SPACE = "\"properties\": ";
// public static final String ID_SPACE = "\"id\": ";
// public static final String FEATURES_SPACE = "\"features\": ";
// public static final String BBOX_SPACE = "\"bbox\": ";
// }
//
// Path: ugeojson-model/src/main/java/org/ugeojson/model/GeoJSONObjectTypeEnum.java
// public enum GeoJSONObjectTypeEnum {
//
// Point(PointDto.class), MultiPoint(MultiPointDto.class), LineString(LineStringDto.class), MultiLineString(
// MultiLineStringDto.class), Polygon(PolygonDto.class), MultiPolygon(
// MultiPolygonDto.class), GeometryCollection(GeometryCollectionDto.class), Feature(
// FeatureDto.class), FeatureCollection(FeatureCollectionDto.class);
//
// private final Class dtoClass;
//
// private GeoJSONObjectTypeEnum(Class dtoClass) {
// this.dtoClass = dtoClass;
// }
//
// public Class getDtoClass() {
// return dtoClass;
// }
// }
//
// Path: ugeojson-model/src/main/java/org/ugeojson/model/geometry/GeometryCollectionDto.java
// public class GeometryCollectionDto extends GeometryDto {
//
// private static final long serialVersionUID = 1L;
//
// private List<GeometryDto> geometries;
//
// public List<GeometryDto> getGeometries() {
// return geometries;
// }
//
// public void setGeometries(List<GeometryDto> geometries) {
// this.geometries = geometries;
// }
//
// @Override
// public GeoJSONObjectTypeEnum getGeoJSONObjectType() {
// return GeoJSONObjectTypeEnum.GeometryCollection;
// }
// }
//
// Path: ugeojson-model/src/main/java/org/ugeojson/model/geometry/GeometryDto.java
// public abstract class GeometryDto extends GeoJSONObjectDto {
//
// private static final long serialVersionUID = 1L;
//
// }
| import java.util.List;
import org.ugeojson.builder.common.BuilderConstants;
import org.ugeojson.model.GeoJSONObjectTypeEnum;
import org.ugeojson.model.geometry.GeometryCollectionDto;
import org.ugeojson.model.geometry.GeometryDto; | package org.ugeojson.builder.geometry;
/**
* @author moksuzer
*
*/
public class GeometryCollectionBuilder extends GeometryBuilder<GeometryCollectionDto> {
private static final GeometryCollectionBuilder INSTANCE = new GeometryCollectionBuilder();
public static GeometryCollectionBuilder getInstance() {
return INSTANCE;
}
private GeometryCollectionBuilder() {
}
/*
* (non-Javadoc)
*
* @see
* org.ugeojson.builder.geometry.GeometryBuilder#toGeometryGeoJSON(com
* .erumi.ugeojson.model.geometry.GeometryDto)
*/
@Override
public String toGeoJSON(GeometryCollectionDto geometryCollection) {
if (geometryCollection == null) { | // Path: ugeojson-builder/src/main/java/org/ugeojson/builder/common/BuilderConstants.java
// public interface BuilderConstants {
//
// public static final String OPEN_BRACKET = "[";
// public static final String CLOSE_BRACKET = "]";
// public static final String OPEN_CURLY_BRACE = "{";
// public static final String CLOSE_CURLY_BRACE = "}";
//
// public static final String COMMA_SPACE = ", ";
// public static final String COMMA = ",";
// public static final String SPACE = " ";
// public static final String COMMA_NEWLINE = ",\n";
// public static final String NEWLINE = "\n";
// public static final String DOUBLE_QUOTE = "\"";
// public static final String NULL_VALUE = "null";
// public static final String TAB_SPACE = " ";
// public static final String EMPTY = "";
//
// public static final String TYPE_SPACE = "\"type\": ";
// public static final String COORDINATES_SPACE = "\"coordinates\": ";
// public static final String GEOMETRIES_SPACE = "\"geometries\": ";
// public static final String GEOMETRY_SPACE = "\"geometry\": ";
// public static final String PROPERTIES_SPACE = "\"properties\": ";
// public static final String ID_SPACE = "\"id\": ";
// public static final String FEATURES_SPACE = "\"features\": ";
// public static final String BBOX_SPACE = "\"bbox\": ";
// }
//
// Path: ugeojson-model/src/main/java/org/ugeojson/model/GeoJSONObjectTypeEnum.java
// public enum GeoJSONObjectTypeEnum {
//
// Point(PointDto.class), MultiPoint(MultiPointDto.class), LineString(LineStringDto.class), MultiLineString(
// MultiLineStringDto.class), Polygon(PolygonDto.class), MultiPolygon(
// MultiPolygonDto.class), GeometryCollection(GeometryCollectionDto.class), Feature(
// FeatureDto.class), FeatureCollection(FeatureCollectionDto.class);
//
// private final Class dtoClass;
//
// private GeoJSONObjectTypeEnum(Class dtoClass) {
// this.dtoClass = dtoClass;
// }
//
// public Class getDtoClass() {
// return dtoClass;
// }
// }
//
// Path: ugeojson-model/src/main/java/org/ugeojson/model/geometry/GeometryCollectionDto.java
// public class GeometryCollectionDto extends GeometryDto {
//
// private static final long serialVersionUID = 1L;
//
// private List<GeometryDto> geometries;
//
// public List<GeometryDto> getGeometries() {
// return geometries;
// }
//
// public void setGeometries(List<GeometryDto> geometries) {
// this.geometries = geometries;
// }
//
// @Override
// public GeoJSONObjectTypeEnum getGeoJSONObjectType() {
// return GeoJSONObjectTypeEnum.GeometryCollection;
// }
// }
//
// Path: ugeojson-model/src/main/java/org/ugeojson/model/geometry/GeometryDto.java
// public abstract class GeometryDto extends GeoJSONObjectDto {
//
// private static final long serialVersionUID = 1L;
//
// }
// Path: ugeojson-builder/src/main/java/org/ugeojson/builder/geometry/GeometryCollectionBuilder.java
import java.util.List;
import org.ugeojson.builder.common.BuilderConstants;
import org.ugeojson.model.GeoJSONObjectTypeEnum;
import org.ugeojson.model.geometry.GeometryCollectionDto;
import org.ugeojson.model.geometry.GeometryDto;
package org.ugeojson.builder.geometry;
/**
* @author moksuzer
*
*/
public class GeometryCollectionBuilder extends GeometryBuilder<GeometryCollectionDto> {
private static final GeometryCollectionBuilder INSTANCE = new GeometryCollectionBuilder();
public static GeometryCollectionBuilder getInstance() {
return INSTANCE;
}
private GeometryCollectionBuilder() {
}
/*
* (non-Javadoc)
*
* @see
* org.ugeojson.builder.geometry.GeometryBuilder#toGeometryGeoJSON(com
* .erumi.ugeojson.model.geometry.GeometryDto)
*/
@Override
public String toGeoJSON(GeometryCollectionDto geometryCollection) {
if (geometryCollection == null) { | return BuilderConstants.NULL_VALUE; |
mokszr/ultimate-geojson | ugeojson-builder/src/main/java/org/ugeojson/builder/geometry/GeometryCollectionBuilder.java | // Path: ugeojson-builder/src/main/java/org/ugeojson/builder/common/BuilderConstants.java
// public interface BuilderConstants {
//
// public static final String OPEN_BRACKET = "[";
// public static final String CLOSE_BRACKET = "]";
// public static final String OPEN_CURLY_BRACE = "{";
// public static final String CLOSE_CURLY_BRACE = "}";
//
// public static final String COMMA_SPACE = ", ";
// public static final String COMMA = ",";
// public static final String SPACE = " ";
// public static final String COMMA_NEWLINE = ",\n";
// public static final String NEWLINE = "\n";
// public static final String DOUBLE_QUOTE = "\"";
// public static final String NULL_VALUE = "null";
// public static final String TAB_SPACE = " ";
// public static final String EMPTY = "";
//
// public static final String TYPE_SPACE = "\"type\": ";
// public static final String COORDINATES_SPACE = "\"coordinates\": ";
// public static final String GEOMETRIES_SPACE = "\"geometries\": ";
// public static final String GEOMETRY_SPACE = "\"geometry\": ";
// public static final String PROPERTIES_SPACE = "\"properties\": ";
// public static final String ID_SPACE = "\"id\": ";
// public static final String FEATURES_SPACE = "\"features\": ";
// public static final String BBOX_SPACE = "\"bbox\": ";
// }
//
// Path: ugeojson-model/src/main/java/org/ugeojson/model/GeoJSONObjectTypeEnum.java
// public enum GeoJSONObjectTypeEnum {
//
// Point(PointDto.class), MultiPoint(MultiPointDto.class), LineString(LineStringDto.class), MultiLineString(
// MultiLineStringDto.class), Polygon(PolygonDto.class), MultiPolygon(
// MultiPolygonDto.class), GeometryCollection(GeometryCollectionDto.class), Feature(
// FeatureDto.class), FeatureCollection(FeatureCollectionDto.class);
//
// private final Class dtoClass;
//
// private GeoJSONObjectTypeEnum(Class dtoClass) {
// this.dtoClass = dtoClass;
// }
//
// public Class getDtoClass() {
// return dtoClass;
// }
// }
//
// Path: ugeojson-model/src/main/java/org/ugeojson/model/geometry/GeometryCollectionDto.java
// public class GeometryCollectionDto extends GeometryDto {
//
// private static final long serialVersionUID = 1L;
//
// private List<GeometryDto> geometries;
//
// public List<GeometryDto> getGeometries() {
// return geometries;
// }
//
// public void setGeometries(List<GeometryDto> geometries) {
// this.geometries = geometries;
// }
//
// @Override
// public GeoJSONObjectTypeEnum getGeoJSONObjectType() {
// return GeoJSONObjectTypeEnum.GeometryCollection;
// }
// }
//
// Path: ugeojson-model/src/main/java/org/ugeojson/model/geometry/GeometryDto.java
// public abstract class GeometryDto extends GeoJSONObjectDto {
//
// private static final long serialVersionUID = 1L;
//
// }
| import java.util.List;
import org.ugeojson.builder.common.BuilderConstants;
import org.ugeojson.model.GeoJSONObjectTypeEnum;
import org.ugeojson.model.geometry.GeometryCollectionDto;
import org.ugeojson.model.geometry.GeometryDto; | package org.ugeojson.builder.geometry;
/**
* @author moksuzer
*
*/
public class GeometryCollectionBuilder extends GeometryBuilder<GeometryCollectionDto> {
private static final GeometryCollectionBuilder INSTANCE = new GeometryCollectionBuilder();
public static GeometryCollectionBuilder getInstance() {
return INSTANCE;
}
private GeometryCollectionBuilder() {
}
/*
* (non-Javadoc)
*
* @see
* org.ugeojson.builder.geometry.GeometryBuilder#toGeometryGeoJSON(com
* .erumi.ugeojson.model.geometry.GeometryDto)
*/
@Override
public String toGeoJSON(GeometryCollectionDto geometryCollection) {
if (geometryCollection == null) {
return BuilderConstants.NULL_VALUE;
}
StringBuilder builder = initializeBuilder(); | // Path: ugeojson-builder/src/main/java/org/ugeojson/builder/common/BuilderConstants.java
// public interface BuilderConstants {
//
// public static final String OPEN_BRACKET = "[";
// public static final String CLOSE_BRACKET = "]";
// public static final String OPEN_CURLY_BRACE = "{";
// public static final String CLOSE_CURLY_BRACE = "}";
//
// public static final String COMMA_SPACE = ", ";
// public static final String COMMA = ",";
// public static final String SPACE = " ";
// public static final String COMMA_NEWLINE = ",\n";
// public static final String NEWLINE = "\n";
// public static final String DOUBLE_QUOTE = "\"";
// public static final String NULL_VALUE = "null";
// public static final String TAB_SPACE = " ";
// public static final String EMPTY = "";
//
// public static final String TYPE_SPACE = "\"type\": ";
// public static final String COORDINATES_SPACE = "\"coordinates\": ";
// public static final String GEOMETRIES_SPACE = "\"geometries\": ";
// public static final String GEOMETRY_SPACE = "\"geometry\": ";
// public static final String PROPERTIES_SPACE = "\"properties\": ";
// public static final String ID_SPACE = "\"id\": ";
// public static final String FEATURES_SPACE = "\"features\": ";
// public static final String BBOX_SPACE = "\"bbox\": ";
// }
//
// Path: ugeojson-model/src/main/java/org/ugeojson/model/GeoJSONObjectTypeEnum.java
// public enum GeoJSONObjectTypeEnum {
//
// Point(PointDto.class), MultiPoint(MultiPointDto.class), LineString(LineStringDto.class), MultiLineString(
// MultiLineStringDto.class), Polygon(PolygonDto.class), MultiPolygon(
// MultiPolygonDto.class), GeometryCollection(GeometryCollectionDto.class), Feature(
// FeatureDto.class), FeatureCollection(FeatureCollectionDto.class);
//
// private final Class dtoClass;
//
// private GeoJSONObjectTypeEnum(Class dtoClass) {
// this.dtoClass = dtoClass;
// }
//
// public Class getDtoClass() {
// return dtoClass;
// }
// }
//
// Path: ugeojson-model/src/main/java/org/ugeojson/model/geometry/GeometryCollectionDto.java
// public class GeometryCollectionDto extends GeometryDto {
//
// private static final long serialVersionUID = 1L;
//
// private List<GeometryDto> geometries;
//
// public List<GeometryDto> getGeometries() {
// return geometries;
// }
//
// public void setGeometries(List<GeometryDto> geometries) {
// this.geometries = geometries;
// }
//
// @Override
// public GeoJSONObjectTypeEnum getGeoJSONObjectType() {
// return GeoJSONObjectTypeEnum.GeometryCollection;
// }
// }
//
// Path: ugeojson-model/src/main/java/org/ugeojson/model/geometry/GeometryDto.java
// public abstract class GeometryDto extends GeoJSONObjectDto {
//
// private static final long serialVersionUID = 1L;
//
// }
// Path: ugeojson-builder/src/main/java/org/ugeojson/builder/geometry/GeometryCollectionBuilder.java
import java.util.List;
import org.ugeojson.builder.common.BuilderConstants;
import org.ugeojson.model.GeoJSONObjectTypeEnum;
import org.ugeojson.model.geometry.GeometryCollectionDto;
import org.ugeojson.model.geometry.GeometryDto;
package org.ugeojson.builder.geometry;
/**
* @author moksuzer
*
*/
public class GeometryCollectionBuilder extends GeometryBuilder<GeometryCollectionDto> {
private static final GeometryCollectionBuilder INSTANCE = new GeometryCollectionBuilder();
public static GeometryCollectionBuilder getInstance() {
return INSTANCE;
}
private GeometryCollectionBuilder() {
}
/*
* (non-Javadoc)
*
* @see
* org.ugeojson.builder.geometry.GeometryBuilder#toGeometryGeoJSON(com
* .erumi.ugeojson.model.geometry.GeometryDto)
*/
@Override
public String toGeoJSON(GeometryCollectionDto geometryCollection) {
if (geometryCollection == null) {
return BuilderConstants.NULL_VALUE;
}
StringBuilder builder = initializeBuilder(); | buildTypePart(builder, GeoJSONObjectTypeEnum.GeometryCollection); |
mokszr/ultimate-geojson | ugeojson-builder/src/main/java/org/ugeojson/builder/geometry/GeometryCollectionBuilder.java | // Path: ugeojson-builder/src/main/java/org/ugeojson/builder/common/BuilderConstants.java
// public interface BuilderConstants {
//
// public static final String OPEN_BRACKET = "[";
// public static final String CLOSE_BRACKET = "]";
// public static final String OPEN_CURLY_BRACE = "{";
// public static final String CLOSE_CURLY_BRACE = "}";
//
// public static final String COMMA_SPACE = ", ";
// public static final String COMMA = ",";
// public static final String SPACE = " ";
// public static final String COMMA_NEWLINE = ",\n";
// public static final String NEWLINE = "\n";
// public static final String DOUBLE_QUOTE = "\"";
// public static final String NULL_VALUE = "null";
// public static final String TAB_SPACE = " ";
// public static final String EMPTY = "";
//
// public static final String TYPE_SPACE = "\"type\": ";
// public static final String COORDINATES_SPACE = "\"coordinates\": ";
// public static final String GEOMETRIES_SPACE = "\"geometries\": ";
// public static final String GEOMETRY_SPACE = "\"geometry\": ";
// public static final String PROPERTIES_SPACE = "\"properties\": ";
// public static final String ID_SPACE = "\"id\": ";
// public static final String FEATURES_SPACE = "\"features\": ";
// public static final String BBOX_SPACE = "\"bbox\": ";
// }
//
// Path: ugeojson-model/src/main/java/org/ugeojson/model/GeoJSONObjectTypeEnum.java
// public enum GeoJSONObjectTypeEnum {
//
// Point(PointDto.class), MultiPoint(MultiPointDto.class), LineString(LineStringDto.class), MultiLineString(
// MultiLineStringDto.class), Polygon(PolygonDto.class), MultiPolygon(
// MultiPolygonDto.class), GeometryCollection(GeometryCollectionDto.class), Feature(
// FeatureDto.class), FeatureCollection(FeatureCollectionDto.class);
//
// private final Class dtoClass;
//
// private GeoJSONObjectTypeEnum(Class dtoClass) {
// this.dtoClass = dtoClass;
// }
//
// public Class getDtoClass() {
// return dtoClass;
// }
// }
//
// Path: ugeojson-model/src/main/java/org/ugeojson/model/geometry/GeometryCollectionDto.java
// public class GeometryCollectionDto extends GeometryDto {
//
// private static final long serialVersionUID = 1L;
//
// private List<GeometryDto> geometries;
//
// public List<GeometryDto> getGeometries() {
// return geometries;
// }
//
// public void setGeometries(List<GeometryDto> geometries) {
// this.geometries = geometries;
// }
//
// @Override
// public GeoJSONObjectTypeEnum getGeoJSONObjectType() {
// return GeoJSONObjectTypeEnum.GeometryCollection;
// }
// }
//
// Path: ugeojson-model/src/main/java/org/ugeojson/model/geometry/GeometryDto.java
// public abstract class GeometryDto extends GeoJSONObjectDto {
//
// private static final long serialVersionUID = 1L;
//
// }
| import java.util.List;
import org.ugeojson.builder.common.BuilderConstants;
import org.ugeojson.model.GeoJSONObjectTypeEnum;
import org.ugeojson.model.geometry.GeometryCollectionDto;
import org.ugeojson.model.geometry.GeometryDto; | package org.ugeojson.builder.geometry;
/**
* @author moksuzer
*
*/
public class GeometryCollectionBuilder extends GeometryBuilder<GeometryCollectionDto> {
private static final GeometryCollectionBuilder INSTANCE = new GeometryCollectionBuilder();
public static GeometryCollectionBuilder getInstance() {
return INSTANCE;
}
private GeometryCollectionBuilder() {
}
/*
* (non-Javadoc)
*
* @see
* org.ugeojson.builder.geometry.GeometryBuilder#toGeometryGeoJSON(com
* .erumi.ugeojson.model.geometry.GeometryDto)
*/
@Override
public String toGeoJSON(GeometryCollectionDto geometryCollection) {
if (geometryCollection == null) {
return BuilderConstants.NULL_VALUE;
}
StringBuilder builder = initializeBuilder();
buildTypePart(builder, GeoJSONObjectTypeEnum.GeometryCollection);
builder.append(BuilderConstants.GEOMETRIES_SPACE);
builder.append(BuilderConstants.OPEN_BRACKET);
| // Path: ugeojson-builder/src/main/java/org/ugeojson/builder/common/BuilderConstants.java
// public interface BuilderConstants {
//
// public static final String OPEN_BRACKET = "[";
// public static final String CLOSE_BRACKET = "]";
// public static final String OPEN_CURLY_BRACE = "{";
// public static final String CLOSE_CURLY_BRACE = "}";
//
// public static final String COMMA_SPACE = ", ";
// public static final String COMMA = ",";
// public static final String SPACE = " ";
// public static final String COMMA_NEWLINE = ",\n";
// public static final String NEWLINE = "\n";
// public static final String DOUBLE_QUOTE = "\"";
// public static final String NULL_VALUE = "null";
// public static final String TAB_SPACE = " ";
// public static final String EMPTY = "";
//
// public static final String TYPE_SPACE = "\"type\": ";
// public static final String COORDINATES_SPACE = "\"coordinates\": ";
// public static final String GEOMETRIES_SPACE = "\"geometries\": ";
// public static final String GEOMETRY_SPACE = "\"geometry\": ";
// public static final String PROPERTIES_SPACE = "\"properties\": ";
// public static final String ID_SPACE = "\"id\": ";
// public static final String FEATURES_SPACE = "\"features\": ";
// public static final String BBOX_SPACE = "\"bbox\": ";
// }
//
// Path: ugeojson-model/src/main/java/org/ugeojson/model/GeoJSONObjectTypeEnum.java
// public enum GeoJSONObjectTypeEnum {
//
// Point(PointDto.class), MultiPoint(MultiPointDto.class), LineString(LineStringDto.class), MultiLineString(
// MultiLineStringDto.class), Polygon(PolygonDto.class), MultiPolygon(
// MultiPolygonDto.class), GeometryCollection(GeometryCollectionDto.class), Feature(
// FeatureDto.class), FeatureCollection(FeatureCollectionDto.class);
//
// private final Class dtoClass;
//
// private GeoJSONObjectTypeEnum(Class dtoClass) {
// this.dtoClass = dtoClass;
// }
//
// public Class getDtoClass() {
// return dtoClass;
// }
// }
//
// Path: ugeojson-model/src/main/java/org/ugeojson/model/geometry/GeometryCollectionDto.java
// public class GeometryCollectionDto extends GeometryDto {
//
// private static final long serialVersionUID = 1L;
//
// private List<GeometryDto> geometries;
//
// public List<GeometryDto> getGeometries() {
// return geometries;
// }
//
// public void setGeometries(List<GeometryDto> geometries) {
// this.geometries = geometries;
// }
//
// @Override
// public GeoJSONObjectTypeEnum getGeoJSONObjectType() {
// return GeoJSONObjectTypeEnum.GeometryCollection;
// }
// }
//
// Path: ugeojson-model/src/main/java/org/ugeojson/model/geometry/GeometryDto.java
// public abstract class GeometryDto extends GeoJSONObjectDto {
//
// private static final long serialVersionUID = 1L;
//
// }
// Path: ugeojson-builder/src/main/java/org/ugeojson/builder/geometry/GeometryCollectionBuilder.java
import java.util.List;
import org.ugeojson.builder.common.BuilderConstants;
import org.ugeojson.model.GeoJSONObjectTypeEnum;
import org.ugeojson.model.geometry.GeometryCollectionDto;
import org.ugeojson.model.geometry.GeometryDto;
package org.ugeojson.builder.geometry;
/**
* @author moksuzer
*
*/
public class GeometryCollectionBuilder extends GeometryBuilder<GeometryCollectionDto> {
private static final GeometryCollectionBuilder INSTANCE = new GeometryCollectionBuilder();
public static GeometryCollectionBuilder getInstance() {
return INSTANCE;
}
private GeometryCollectionBuilder() {
}
/*
* (non-Javadoc)
*
* @see
* org.ugeojson.builder.geometry.GeometryBuilder#toGeometryGeoJSON(com
* .erumi.ugeojson.model.geometry.GeometryDto)
*/
@Override
public String toGeoJSON(GeometryCollectionDto geometryCollection) {
if (geometryCollection == null) {
return BuilderConstants.NULL_VALUE;
}
StringBuilder builder = initializeBuilder();
buildTypePart(builder, GeoJSONObjectTypeEnum.GeometryCollection);
builder.append(BuilderConstants.GEOMETRIES_SPACE);
builder.append(BuilderConstants.OPEN_BRACKET);
| List<GeometryDto> geometries = geometryCollection.getGeometries(); |
mokszr/ultimate-geojson | ugeojson-parser/src/test/java/org/ugeojson/parser/deserializer/MultiPointDeserializerShould.java | // Path: ugeojson-model/src/main/java/org/ugeojson/model/PositionDto.java
// public class PositionDto implements Serializable {
//
// private static final long serialVersionUID = 1L;
//
// private double[] numbers;
//
// /**
// * This constructor initializes numbers field to hold two double numbers. Do
// * not use this constructor if you need the third elevation parameter.
// */
// public PositionDto() {
// this.numbers = new double[2];
// }
//
// /**
// * Simple coordinate position constructor
// *
// * @param longitude
// * @param latitude
// */
// public PositionDto(double longitude, double latitude) {
// this.numbers = new double[] { longitude, latitude };
// }
//
// /**
// * Use this constructor if you need elevation parameter
// *
// * @param longitude
// * @param latitude
// * @param elevation
// */
// public PositionDto(double longitude, double latitude, double elevation) {
// this.numbers = new double[] { longitude, latitude, elevation };
// }
//
// /**
// * Copy constructor
// *
// * @param position
// */
// public PositionDto(PositionDto position) {
// if (position != null) {
// double[] copyNumbers = position.getNumbers();
// this.numbers = new double[copyNumbers.length];
// for (int i = 0; i < copyNumbers.length; i++) {
// this.numbers[i] = copyNumbers[i];
// }
// }
// }
//
// @Override
// public String toString() {
// if (numbers == null) {
// return "null numbers[]";
// }
// StringBuilder value = new StringBuilder("[");
// for (int i = 0; i < numbers.length; i++) {
// value.append(numbers[i]);
// if (i < numbers.length - 1) {
// value.append(", ");
// }
// }
// value.append("]");
// return value.toString();
// }
//
// public void setLongitude(double longitude) {
// this.numbers[0] = longitude;
// }
//
// public double getLongitude() {
// return numbers[0];
// }
//
// public void setLatitude(double latitude) {
// this.numbers[1] = latitude;
// }
//
// public double getLatitude() {
// return numbers[1];
// }
//
// public void setElevation(double elevation) {
// this.numbers[2] = elevation;
// }
//
// public double getElevation() {
// return numbers[2];
// }
//
// public double[] getNumbers() {
// return numbers;
// }
//
// public void setNumbers(double[] numbers) {
// this.numbers = numbers;
// }
// }
//
// Path: ugeojson-model/src/main/java/org/ugeojson/model/geometry/MultiPointDto.java
// public class MultiPointDto extends GeometryDto {
//
// private static final long serialVersionUID = 1L;
//
// private List<PositionDto> positions;
//
// public List<PositionDto> getPositions() {
// return positions;
// }
//
// public void setPositions(List<PositionDto> positions) {
// this.positions = positions;
// }
//
// @Override
// public GeoJSONObjectTypeEnum getGeoJSONObjectType() {
// return GeoJSONObjectTypeEnum.MultiPoint;
// }
// }
//
// Path: ugeojson-parser/src/main/java/org/ugeojson/parser/deserializer/MultiPointDeserializer.java
// public class MultiPointDeserializer implements JsonDeserializer<MultiPointDto> {
//
// @Override
// public MultiPointDto deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) {
//
// MultiPointDto dto = new MultiPointDto();
// List<PositionDto> positions = new ArrayList<>();
// dto.setPositions(positions);
//
// JsonObject asJsonObject = json.getAsJsonObject();
// JsonArray jsonArray = asJsonObject.get("coordinates").getAsJsonArray();
// for (int i = 0; i < jsonArray.size(); i++) {
// PositionDto position = context.deserialize(jsonArray.get(i), PositionDto.class);
// positions.add(position);
// }
//
// dto.setBbox(BoundingBoxParser.parseBbox(asJsonObject, context));
//
// return dto;
// }
//
// }
//
// Path: ugeojson-parser/src/main/java/org/ugeojson/parser/deserializer/PositionDeserializer.java
// public class PositionDeserializer implements JsonDeserializer<PositionDto> {
//
// @Override
// public PositionDto deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) {
//
// JsonArray asJsonArray = json.getAsJsonArray();
// double[] numbers = new double[asJsonArray.size()];
// for (int i = 0; i < asJsonArray.size(); i++) {
// numbers[i] = asJsonArray.get(i).getAsDouble();
// }
//
// PositionDto positionDto = new PositionDto();
// positionDto.setNumbers(numbers);
// return positionDto;
// }
//
// }
| import static org.hamcrest.CoreMatchers.equalTo;
import static org.junit.Assert.assertThat;
import org.junit.Test;
import org.ugeojson.model.PositionDto;
import org.ugeojson.model.geometry.MultiPointDto;
import org.ugeojson.parser.deserializer.MultiPointDeserializer;
import org.ugeojson.parser.deserializer.PositionDeserializer;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder; | package org.ugeojson.parser.deserializer;
public class MultiPointDeserializerShould {
@Test public void
deserialize_linestring(){
GsonBuilder gsonBuilder = new GsonBuilder(); | // Path: ugeojson-model/src/main/java/org/ugeojson/model/PositionDto.java
// public class PositionDto implements Serializable {
//
// private static final long serialVersionUID = 1L;
//
// private double[] numbers;
//
// /**
// * This constructor initializes numbers field to hold two double numbers. Do
// * not use this constructor if you need the third elevation parameter.
// */
// public PositionDto() {
// this.numbers = new double[2];
// }
//
// /**
// * Simple coordinate position constructor
// *
// * @param longitude
// * @param latitude
// */
// public PositionDto(double longitude, double latitude) {
// this.numbers = new double[] { longitude, latitude };
// }
//
// /**
// * Use this constructor if you need elevation parameter
// *
// * @param longitude
// * @param latitude
// * @param elevation
// */
// public PositionDto(double longitude, double latitude, double elevation) {
// this.numbers = new double[] { longitude, latitude, elevation };
// }
//
// /**
// * Copy constructor
// *
// * @param position
// */
// public PositionDto(PositionDto position) {
// if (position != null) {
// double[] copyNumbers = position.getNumbers();
// this.numbers = new double[copyNumbers.length];
// for (int i = 0; i < copyNumbers.length; i++) {
// this.numbers[i] = copyNumbers[i];
// }
// }
// }
//
// @Override
// public String toString() {
// if (numbers == null) {
// return "null numbers[]";
// }
// StringBuilder value = new StringBuilder("[");
// for (int i = 0; i < numbers.length; i++) {
// value.append(numbers[i]);
// if (i < numbers.length - 1) {
// value.append(", ");
// }
// }
// value.append("]");
// return value.toString();
// }
//
// public void setLongitude(double longitude) {
// this.numbers[0] = longitude;
// }
//
// public double getLongitude() {
// return numbers[0];
// }
//
// public void setLatitude(double latitude) {
// this.numbers[1] = latitude;
// }
//
// public double getLatitude() {
// return numbers[1];
// }
//
// public void setElevation(double elevation) {
// this.numbers[2] = elevation;
// }
//
// public double getElevation() {
// return numbers[2];
// }
//
// public double[] getNumbers() {
// return numbers;
// }
//
// public void setNumbers(double[] numbers) {
// this.numbers = numbers;
// }
// }
//
// Path: ugeojson-model/src/main/java/org/ugeojson/model/geometry/MultiPointDto.java
// public class MultiPointDto extends GeometryDto {
//
// private static final long serialVersionUID = 1L;
//
// private List<PositionDto> positions;
//
// public List<PositionDto> getPositions() {
// return positions;
// }
//
// public void setPositions(List<PositionDto> positions) {
// this.positions = positions;
// }
//
// @Override
// public GeoJSONObjectTypeEnum getGeoJSONObjectType() {
// return GeoJSONObjectTypeEnum.MultiPoint;
// }
// }
//
// Path: ugeojson-parser/src/main/java/org/ugeojson/parser/deserializer/MultiPointDeserializer.java
// public class MultiPointDeserializer implements JsonDeserializer<MultiPointDto> {
//
// @Override
// public MultiPointDto deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) {
//
// MultiPointDto dto = new MultiPointDto();
// List<PositionDto> positions = new ArrayList<>();
// dto.setPositions(positions);
//
// JsonObject asJsonObject = json.getAsJsonObject();
// JsonArray jsonArray = asJsonObject.get("coordinates").getAsJsonArray();
// for (int i = 0; i < jsonArray.size(); i++) {
// PositionDto position = context.deserialize(jsonArray.get(i), PositionDto.class);
// positions.add(position);
// }
//
// dto.setBbox(BoundingBoxParser.parseBbox(asJsonObject, context));
//
// return dto;
// }
//
// }
//
// Path: ugeojson-parser/src/main/java/org/ugeojson/parser/deserializer/PositionDeserializer.java
// public class PositionDeserializer implements JsonDeserializer<PositionDto> {
//
// @Override
// public PositionDto deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) {
//
// JsonArray asJsonArray = json.getAsJsonArray();
// double[] numbers = new double[asJsonArray.size()];
// for (int i = 0; i < asJsonArray.size(); i++) {
// numbers[i] = asJsonArray.get(i).getAsDouble();
// }
//
// PositionDto positionDto = new PositionDto();
// positionDto.setNumbers(numbers);
// return positionDto;
// }
//
// }
// Path: ugeojson-parser/src/test/java/org/ugeojson/parser/deserializer/MultiPointDeserializerShould.java
import static org.hamcrest.CoreMatchers.equalTo;
import static org.junit.Assert.assertThat;
import org.junit.Test;
import org.ugeojson.model.PositionDto;
import org.ugeojson.model.geometry.MultiPointDto;
import org.ugeojson.parser.deserializer.MultiPointDeserializer;
import org.ugeojson.parser.deserializer.PositionDeserializer;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
package org.ugeojson.parser.deserializer;
public class MultiPointDeserializerShould {
@Test public void
deserialize_linestring(){
GsonBuilder gsonBuilder = new GsonBuilder(); | gsonBuilder.registerTypeAdapter(PositionDto.class, new PositionDeserializer()); |
mokszr/ultimate-geojson | ugeojson-parser/src/test/java/org/ugeojson/parser/deserializer/MultiPointDeserializerShould.java | // Path: ugeojson-model/src/main/java/org/ugeojson/model/PositionDto.java
// public class PositionDto implements Serializable {
//
// private static final long serialVersionUID = 1L;
//
// private double[] numbers;
//
// /**
// * This constructor initializes numbers field to hold two double numbers. Do
// * not use this constructor if you need the third elevation parameter.
// */
// public PositionDto() {
// this.numbers = new double[2];
// }
//
// /**
// * Simple coordinate position constructor
// *
// * @param longitude
// * @param latitude
// */
// public PositionDto(double longitude, double latitude) {
// this.numbers = new double[] { longitude, latitude };
// }
//
// /**
// * Use this constructor if you need elevation parameter
// *
// * @param longitude
// * @param latitude
// * @param elevation
// */
// public PositionDto(double longitude, double latitude, double elevation) {
// this.numbers = new double[] { longitude, latitude, elevation };
// }
//
// /**
// * Copy constructor
// *
// * @param position
// */
// public PositionDto(PositionDto position) {
// if (position != null) {
// double[] copyNumbers = position.getNumbers();
// this.numbers = new double[copyNumbers.length];
// for (int i = 0; i < copyNumbers.length; i++) {
// this.numbers[i] = copyNumbers[i];
// }
// }
// }
//
// @Override
// public String toString() {
// if (numbers == null) {
// return "null numbers[]";
// }
// StringBuilder value = new StringBuilder("[");
// for (int i = 0; i < numbers.length; i++) {
// value.append(numbers[i]);
// if (i < numbers.length - 1) {
// value.append(", ");
// }
// }
// value.append("]");
// return value.toString();
// }
//
// public void setLongitude(double longitude) {
// this.numbers[0] = longitude;
// }
//
// public double getLongitude() {
// return numbers[0];
// }
//
// public void setLatitude(double latitude) {
// this.numbers[1] = latitude;
// }
//
// public double getLatitude() {
// return numbers[1];
// }
//
// public void setElevation(double elevation) {
// this.numbers[2] = elevation;
// }
//
// public double getElevation() {
// return numbers[2];
// }
//
// public double[] getNumbers() {
// return numbers;
// }
//
// public void setNumbers(double[] numbers) {
// this.numbers = numbers;
// }
// }
//
// Path: ugeojson-model/src/main/java/org/ugeojson/model/geometry/MultiPointDto.java
// public class MultiPointDto extends GeometryDto {
//
// private static final long serialVersionUID = 1L;
//
// private List<PositionDto> positions;
//
// public List<PositionDto> getPositions() {
// return positions;
// }
//
// public void setPositions(List<PositionDto> positions) {
// this.positions = positions;
// }
//
// @Override
// public GeoJSONObjectTypeEnum getGeoJSONObjectType() {
// return GeoJSONObjectTypeEnum.MultiPoint;
// }
// }
//
// Path: ugeojson-parser/src/main/java/org/ugeojson/parser/deserializer/MultiPointDeserializer.java
// public class MultiPointDeserializer implements JsonDeserializer<MultiPointDto> {
//
// @Override
// public MultiPointDto deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) {
//
// MultiPointDto dto = new MultiPointDto();
// List<PositionDto> positions = new ArrayList<>();
// dto.setPositions(positions);
//
// JsonObject asJsonObject = json.getAsJsonObject();
// JsonArray jsonArray = asJsonObject.get("coordinates").getAsJsonArray();
// for (int i = 0; i < jsonArray.size(); i++) {
// PositionDto position = context.deserialize(jsonArray.get(i), PositionDto.class);
// positions.add(position);
// }
//
// dto.setBbox(BoundingBoxParser.parseBbox(asJsonObject, context));
//
// return dto;
// }
//
// }
//
// Path: ugeojson-parser/src/main/java/org/ugeojson/parser/deserializer/PositionDeserializer.java
// public class PositionDeserializer implements JsonDeserializer<PositionDto> {
//
// @Override
// public PositionDto deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) {
//
// JsonArray asJsonArray = json.getAsJsonArray();
// double[] numbers = new double[asJsonArray.size()];
// for (int i = 0; i < asJsonArray.size(); i++) {
// numbers[i] = asJsonArray.get(i).getAsDouble();
// }
//
// PositionDto positionDto = new PositionDto();
// positionDto.setNumbers(numbers);
// return positionDto;
// }
//
// }
| import static org.hamcrest.CoreMatchers.equalTo;
import static org.junit.Assert.assertThat;
import org.junit.Test;
import org.ugeojson.model.PositionDto;
import org.ugeojson.model.geometry.MultiPointDto;
import org.ugeojson.parser.deserializer.MultiPointDeserializer;
import org.ugeojson.parser.deserializer.PositionDeserializer;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder; | package org.ugeojson.parser.deserializer;
public class MultiPointDeserializerShould {
@Test public void
deserialize_linestring(){
GsonBuilder gsonBuilder = new GsonBuilder(); | // Path: ugeojson-model/src/main/java/org/ugeojson/model/PositionDto.java
// public class PositionDto implements Serializable {
//
// private static final long serialVersionUID = 1L;
//
// private double[] numbers;
//
// /**
// * This constructor initializes numbers field to hold two double numbers. Do
// * not use this constructor if you need the third elevation parameter.
// */
// public PositionDto() {
// this.numbers = new double[2];
// }
//
// /**
// * Simple coordinate position constructor
// *
// * @param longitude
// * @param latitude
// */
// public PositionDto(double longitude, double latitude) {
// this.numbers = new double[] { longitude, latitude };
// }
//
// /**
// * Use this constructor if you need elevation parameter
// *
// * @param longitude
// * @param latitude
// * @param elevation
// */
// public PositionDto(double longitude, double latitude, double elevation) {
// this.numbers = new double[] { longitude, latitude, elevation };
// }
//
// /**
// * Copy constructor
// *
// * @param position
// */
// public PositionDto(PositionDto position) {
// if (position != null) {
// double[] copyNumbers = position.getNumbers();
// this.numbers = new double[copyNumbers.length];
// for (int i = 0; i < copyNumbers.length; i++) {
// this.numbers[i] = copyNumbers[i];
// }
// }
// }
//
// @Override
// public String toString() {
// if (numbers == null) {
// return "null numbers[]";
// }
// StringBuilder value = new StringBuilder("[");
// for (int i = 0; i < numbers.length; i++) {
// value.append(numbers[i]);
// if (i < numbers.length - 1) {
// value.append(", ");
// }
// }
// value.append("]");
// return value.toString();
// }
//
// public void setLongitude(double longitude) {
// this.numbers[0] = longitude;
// }
//
// public double getLongitude() {
// return numbers[0];
// }
//
// public void setLatitude(double latitude) {
// this.numbers[1] = latitude;
// }
//
// public double getLatitude() {
// return numbers[1];
// }
//
// public void setElevation(double elevation) {
// this.numbers[2] = elevation;
// }
//
// public double getElevation() {
// return numbers[2];
// }
//
// public double[] getNumbers() {
// return numbers;
// }
//
// public void setNumbers(double[] numbers) {
// this.numbers = numbers;
// }
// }
//
// Path: ugeojson-model/src/main/java/org/ugeojson/model/geometry/MultiPointDto.java
// public class MultiPointDto extends GeometryDto {
//
// private static final long serialVersionUID = 1L;
//
// private List<PositionDto> positions;
//
// public List<PositionDto> getPositions() {
// return positions;
// }
//
// public void setPositions(List<PositionDto> positions) {
// this.positions = positions;
// }
//
// @Override
// public GeoJSONObjectTypeEnum getGeoJSONObjectType() {
// return GeoJSONObjectTypeEnum.MultiPoint;
// }
// }
//
// Path: ugeojson-parser/src/main/java/org/ugeojson/parser/deserializer/MultiPointDeserializer.java
// public class MultiPointDeserializer implements JsonDeserializer<MultiPointDto> {
//
// @Override
// public MultiPointDto deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) {
//
// MultiPointDto dto = new MultiPointDto();
// List<PositionDto> positions = new ArrayList<>();
// dto.setPositions(positions);
//
// JsonObject asJsonObject = json.getAsJsonObject();
// JsonArray jsonArray = asJsonObject.get("coordinates").getAsJsonArray();
// for (int i = 0; i < jsonArray.size(); i++) {
// PositionDto position = context.deserialize(jsonArray.get(i), PositionDto.class);
// positions.add(position);
// }
//
// dto.setBbox(BoundingBoxParser.parseBbox(asJsonObject, context));
//
// return dto;
// }
//
// }
//
// Path: ugeojson-parser/src/main/java/org/ugeojson/parser/deserializer/PositionDeserializer.java
// public class PositionDeserializer implements JsonDeserializer<PositionDto> {
//
// @Override
// public PositionDto deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) {
//
// JsonArray asJsonArray = json.getAsJsonArray();
// double[] numbers = new double[asJsonArray.size()];
// for (int i = 0; i < asJsonArray.size(); i++) {
// numbers[i] = asJsonArray.get(i).getAsDouble();
// }
//
// PositionDto positionDto = new PositionDto();
// positionDto.setNumbers(numbers);
// return positionDto;
// }
//
// }
// Path: ugeojson-parser/src/test/java/org/ugeojson/parser/deserializer/MultiPointDeserializerShould.java
import static org.hamcrest.CoreMatchers.equalTo;
import static org.junit.Assert.assertThat;
import org.junit.Test;
import org.ugeojson.model.PositionDto;
import org.ugeojson.model.geometry.MultiPointDto;
import org.ugeojson.parser.deserializer.MultiPointDeserializer;
import org.ugeojson.parser.deserializer.PositionDeserializer;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
package org.ugeojson.parser.deserializer;
public class MultiPointDeserializerShould {
@Test public void
deserialize_linestring(){
GsonBuilder gsonBuilder = new GsonBuilder(); | gsonBuilder.registerTypeAdapter(PositionDto.class, new PositionDeserializer()); |
mokszr/ultimate-geojson | ugeojson-parser/src/test/java/org/ugeojson/parser/deserializer/MultiPointDeserializerShould.java | // Path: ugeojson-model/src/main/java/org/ugeojson/model/PositionDto.java
// public class PositionDto implements Serializable {
//
// private static final long serialVersionUID = 1L;
//
// private double[] numbers;
//
// /**
// * This constructor initializes numbers field to hold two double numbers. Do
// * not use this constructor if you need the third elevation parameter.
// */
// public PositionDto() {
// this.numbers = new double[2];
// }
//
// /**
// * Simple coordinate position constructor
// *
// * @param longitude
// * @param latitude
// */
// public PositionDto(double longitude, double latitude) {
// this.numbers = new double[] { longitude, latitude };
// }
//
// /**
// * Use this constructor if you need elevation parameter
// *
// * @param longitude
// * @param latitude
// * @param elevation
// */
// public PositionDto(double longitude, double latitude, double elevation) {
// this.numbers = new double[] { longitude, latitude, elevation };
// }
//
// /**
// * Copy constructor
// *
// * @param position
// */
// public PositionDto(PositionDto position) {
// if (position != null) {
// double[] copyNumbers = position.getNumbers();
// this.numbers = new double[copyNumbers.length];
// for (int i = 0; i < copyNumbers.length; i++) {
// this.numbers[i] = copyNumbers[i];
// }
// }
// }
//
// @Override
// public String toString() {
// if (numbers == null) {
// return "null numbers[]";
// }
// StringBuilder value = new StringBuilder("[");
// for (int i = 0; i < numbers.length; i++) {
// value.append(numbers[i]);
// if (i < numbers.length - 1) {
// value.append(", ");
// }
// }
// value.append("]");
// return value.toString();
// }
//
// public void setLongitude(double longitude) {
// this.numbers[0] = longitude;
// }
//
// public double getLongitude() {
// return numbers[0];
// }
//
// public void setLatitude(double latitude) {
// this.numbers[1] = latitude;
// }
//
// public double getLatitude() {
// return numbers[1];
// }
//
// public void setElevation(double elevation) {
// this.numbers[2] = elevation;
// }
//
// public double getElevation() {
// return numbers[2];
// }
//
// public double[] getNumbers() {
// return numbers;
// }
//
// public void setNumbers(double[] numbers) {
// this.numbers = numbers;
// }
// }
//
// Path: ugeojson-model/src/main/java/org/ugeojson/model/geometry/MultiPointDto.java
// public class MultiPointDto extends GeometryDto {
//
// private static final long serialVersionUID = 1L;
//
// private List<PositionDto> positions;
//
// public List<PositionDto> getPositions() {
// return positions;
// }
//
// public void setPositions(List<PositionDto> positions) {
// this.positions = positions;
// }
//
// @Override
// public GeoJSONObjectTypeEnum getGeoJSONObjectType() {
// return GeoJSONObjectTypeEnum.MultiPoint;
// }
// }
//
// Path: ugeojson-parser/src/main/java/org/ugeojson/parser/deserializer/MultiPointDeserializer.java
// public class MultiPointDeserializer implements JsonDeserializer<MultiPointDto> {
//
// @Override
// public MultiPointDto deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) {
//
// MultiPointDto dto = new MultiPointDto();
// List<PositionDto> positions = new ArrayList<>();
// dto.setPositions(positions);
//
// JsonObject asJsonObject = json.getAsJsonObject();
// JsonArray jsonArray = asJsonObject.get("coordinates").getAsJsonArray();
// for (int i = 0; i < jsonArray.size(); i++) {
// PositionDto position = context.deserialize(jsonArray.get(i), PositionDto.class);
// positions.add(position);
// }
//
// dto.setBbox(BoundingBoxParser.parseBbox(asJsonObject, context));
//
// return dto;
// }
//
// }
//
// Path: ugeojson-parser/src/main/java/org/ugeojson/parser/deserializer/PositionDeserializer.java
// public class PositionDeserializer implements JsonDeserializer<PositionDto> {
//
// @Override
// public PositionDto deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) {
//
// JsonArray asJsonArray = json.getAsJsonArray();
// double[] numbers = new double[asJsonArray.size()];
// for (int i = 0; i < asJsonArray.size(); i++) {
// numbers[i] = asJsonArray.get(i).getAsDouble();
// }
//
// PositionDto positionDto = new PositionDto();
// positionDto.setNumbers(numbers);
// return positionDto;
// }
//
// }
| import static org.hamcrest.CoreMatchers.equalTo;
import static org.junit.Assert.assertThat;
import org.junit.Test;
import org.ugeojson.model.PositionDto;
import org.ugeojson.model.geometry.MultiPointDto;
import org.ugeojson.parser.deserializer.MultiPointDeserializer;
import org.ugeojson.parser.deserializer.PositionDeserializer;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder; | package org.ugeojson.parser.deserializer;
public class MultiPointDeserializerShould {
@Test public void
deserialize_linestring(){
GsonBuilder gsonBuilder = new GsonBuilder();
gsonBuilder.registerTypeAdapter(PositionDto.class, new PositionDeserializer()); | // Path: ugeojson-model/src/main/java/org/ugeojson/model/PositionDto.java
// public class PositionDto implements Serializable {
//
// private static final long serialVersionUID = 1L;
//
// private double[] numbers;
//
// /**
// * This constructor initializes numbers field to hold two double numbers. Do
// * not use this constructor if you need the third elevation parameter.
// */
// public PositionDto() {
// this.numbers = new double[2];
// }
//
// /**
// * Simple coordinate position constructor
// *
// * @param longitude
// * @param latitude
// */
// public PositionDto(double longitude, double latitude) {
// this.numbers = new double[] { longitude, latitude };
// }
//
// /**
// * Use this constructor if you need elevation parameter
// *
// * @param longitude
// * @param latitude
// * @param elevation
// */
// public PositionDto(double longitude, double latitude, double elevation) {
// this.numbers = new double[] { longitude, latitude, elevation };
// }
//
// /**
// * Copy constructor
// *
// * @param position
// */
// public PositionDto(PositionDto position) {
// if (position != null) {
// double[] copyNumbers = position.getNumbers();
// this.numbers = new double[copyNumbers.length];
// for (int i = 0; i < copyNumbers.length; i++) {
// this.numbers[i] = copyNumbers[i];
// }
// }
// }
//
// @Override
// public String toString() {
// if (numbers == null) {
// return "null numbers[]";
// }
// StringBuilder value = new StringBuilder("[");
// for (int i = 0; i < numbers.length; i++) {
// value.append(numbers[i]);
// if (i < numbers.length - 1) {
// value.append(", ");
// }
// }
// value.append("]");
// return value.toString();
// }
//
// public void setLongitude(double longitude) {
// this.numbers[0] = longitude;
// }
//
// public double getLongitude() {
// return numbers[0];
// }
//
// public void setLatitude(double latitude) {
// this.numbers[1] = latitude;
// }
//
// public double getLatitude() {
// return numbers[1];
// }
//
// public void setElevation(double elevation) {
// this.numbers[2] = elevation;
// }
//
// public double getElevation() {
// return numbers[2];
// }
//
// public double[] getNumbers() {
// return numbers;
// }
//
// public void setNumbers(double[] numbers) {
// this.numbers = numbers;
// }
// }
//
// Path: ugeojson-model/src/main/java/org/ugeojson/model/geometry/MultiPointDto.java
// public class MultiPointDto extends GeometryDto {
//
// private static final long serialVersionUID = 1L;
//
// private List<PositionDto> positions;
//
// public List<PositionDto> getPositions() {
// return positions;
// }
//
// public void setPositions(List<PositionDto> positions) {
// this.positions = positions;
// }
//
// @Override
// public GeoJSONObjectTypeEnum getGeoJSONObjectType() {
// return GeoJSONObjectTypeEnum.MultiPoint;
// }
// }
//
// Path: ugeojson-parser/src/main/java/org/ugeojson/parser/deserializer/MultiPointDeserializer.java
// public class MultiPointDeserializer implements JsonDeserializer<MultiPointDto> {
//
// @Override
// public MultiPointDto deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) {
//
// MultiPointDto dto = new MultiPointDto();
// List<PositionDto> positions = new ArrayList<>();
// dto.setPositions(positions);
//
// JsonObject asJsonObject = json.getAsJsonObject();
// JsonArray jsonArray = asJsonObject.get("coordinates").getAsJsonArray();
// for (int i = 0; i < jsonArray.size(); i++) {
// PositionDto position = context.deserialize(jsonArray.get(i), PositionDto.class);
// positions.add(position);
// }
//
// dto.setBbox(BoundingBoxParser.parseBbox(asJsonObject, context));
//
// return dto;
// }
//
// }
//
// Path: ugeojson-parser/src/main/java/org/ugeojson/parser/deserializer/PositionDeserializer.java
// public class PositionDeserializer implements JsonDeserializer<PositionDto> {
//
// @Override
// public PositionDto deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) {
//
// JsonArray asJsonArray = json.getAsJsonArray();
// double[] numbers = new double[asJsonArray.size()];
// for (int i = 0; i < asJsonArray.size(); i++) {
// numbers[i] = asJsonArray.get(i).getAsDouble();
// }
//
// PositionDto positionDto = new PositionDto();
// positionDto.setNumbers(numbers);
// return positionDto;
// }
//
// }
// Path: ugeojson-parser/src/test/java/org/ugeojson/parser/deserializer/MultiPointDeserializerShould.java
import static org.hamcrest.CoreMatchers.equalTo;
import static org.junit.Assert.assertThat;
import org.junit.Test;
import org.ugeojson.model.PositionDto;
import org.ugeojson.model.geometry.MultiPointDto;
import org.ugeojson.parser.deserializer.MultiPointDeserializer;
import org.ugeojson.parser.deserializer.PositionDeserializer;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
package org.ugeojson.parser.deserializer;
public class MultiPointDeserializerShould {
@Test public void
deserialize_linestring(){
GsonBuilder gsonBuilder = new GsonBuilder();
gsonBuilder.registerTypeAdapter(PositionDto.class, new PositionDeserializer()); | gsonBuilder.registerTypeAdapter(MultiPointDto.class, new MultiPointDeserializer()); |
mokszr/ultimate-geojson | ugeojson-parser/src/test/java/org/ugeojson/parser/deserializer/MultiPointDeserializerShould.java | // Path: ugeojson-model/src/main/java/org/ugeojson/model/PositionDto.java
// public class PositionDto implements Serializable {
//
// private static final long serialVersionUID = 1L;
//
// private double[] numbers;
//
// /**
// * This constructor initializes numbers field to hold two double numbers. Do
// * not use this constructor if you need the third elevation parameter.
// */
// public PositionDto() {
// this.numbers = new double[2];
// }
//
// /**
// * Simple coordinate position constructor
// *
// * @param longitude
// * @param latitude
// */
// public PositionDto(double longitude, double latitude) {
// this.numbers = new double[] { longitude, latitude };
// }
//
// /**
// * Use this constructor if you need elevation parameter
// *
// * @param longitude
// * @param latitude
// * @param elevation
// */
// public PositionDto(double longitude, double latitude, double elevation) {
// this.numbers = new double[] { longitude, latitude, elevation };
// }
//
// /**
// * Copy constructor
// *
// * @param position
// */
// public PositionDto(PositionDto position) {
// if (position != null) {
// double[] copyNumbers = position.getNumbers();
// this.numbers = new double[copyNumbers.length];
// for (int i = 0; i < copyNumbers.length; i++) {
// this.numbers[i] = copyNumbers[i];
// }
// }
// }
//
// @Override
// public String toString() {
// if (numbers == null) {
// return "null numbers[]";
// }
// StringBuilder value = new StringBuilder("[");
// for (int i = 0; i < numbers.length; i++) {
// value.append(numbers[i]);
// if (i < numbers.length - 1) {
// value.append(", ");
// }
// }
// value.append("]");
// return value.toString();
// }
//
// public void setLongitude(double longitude) {
// this.numbers[0] = longitude;
// }
//
// public double getLongitude() {
// return numbers[0];
// }
//
// public void setLatitude(double latitude) {
// this.numbers[1] = latitude;
// }
//
// public double getLatitude() {
// return numbers[1];
// }
//
// public void setElevation(double elevation) {
// this.numbers[2] = elevation;
// }
//
// public double getElevation() {
// return numbers[2];
// }
//
// public double[] getNumbers() {
// return numbers;
// }
//
// public void setNumbers(double[] numbers) {
// this.numbers = numbers;
// }
// }
//
// Path: ugeojson-model/src/main/java/org/ugeojson/model/geometry/MultiPointDto.java
// public class MultiPointDto extends GeometryDto {
//
// private static final long serialVersionUID = 1L;
//
// private List<PositionDto> positions;
//
// public List<PositionDto> getPositions() {
// return positions;
// }
//
// public void setPositions(List<PositionDto> positions) {
// this.positions = positions;
// }
//
// @Override
// public GeoJSONObjectTypeEnum getGeoJSONObjectType() {
// return GeoJSONObjectTypeEnum.MultiPoint;
// }
// }
//
// Path: ugeojson-parser/src/main/java/org/ugeojson/parser/deserializer/MultiPointDeserializer.java
// public class MultiPointDeserializer implements JsonDeserializer<MultiPointDto> {
//
// @Override
// public MultiPointDto deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) {
//
// MultiPointDto dto = new MultiPointDto();
// List<PositionDto> positions = new ArrayList<>();
// dto.setPositions(positions);
//
// JsonObject asJsonObject = json.getAsJsonObject();
// JsonArray jsonArray = asJsonObject.get("coordinates").getAsJsonArray();
// for (int i = 0; i < jsonArray.size(); i++) {
// PositionDto position = context.deserialize(jsonArray.get(i), PositionDto.class);
// positions.add(position);
// }
//
// dto.setBbox(BoundingBoxParser.parseBbox(asJsonObject, context));
//
// return dto;
// }
//
// }
//
// Path: ugeojson-parser/src/main/java/org/ugeojson/parser/deserializer/PositionDeserializer.java
// public class PositionDeserializer implements JsonDeserializer<PositionDto> {
//
// @Override
// public PositionDto deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) {
//
// JsonArray asJsonArray = json.getAsJsonArray();
// double[] numbers = new double[asJsonArray.size()];
// for (int i = 0; i < asJsonArray.size(); i++) {
// numbers[i] = asJsonArray.get(i).getAsDouble();
// }
//
// PositionDto positionDto = new PositionDto();
// positionDto.setNumbers(numbers);
// return positionDto;
// }
//
// }
| import static org.hamcrest.CoreMatchers.equalTo;
import static org.junit.Assert.assertThat;
import org.junit.Test;
import org.ugeojson.model.PositionDto;
import org.ugeojson.model.geometry.MultiPointDto;
import org.ugeojson.parser.deserializer.MultiPointDeserializer;
import org.ugeojson.parser.deserializer.PositionDeserializer;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder; | package org.ugeojson.parser.deserializer;
public class MultiPointDeserializerShould {
@Test public void
deserialize_linestring(){
GsonBuilder gsonBuilder = new GsonBuilder();
gsonBuilder.registerTypeAdapter(PositionDto.class, new PositionDeserializer()); | // Path: ugeojson-model/src/main/java/org/ugeojson/model/PositionDto.java
// public class PositionDto implements Serializable {
//
// private static final long serialVersionUID = 1L;
//
// private double[] numbers;
//
// /**
// * This constructor initializes numbers field to hold two double numbers. Do
// * not use this constructor if you need the third elevation parameter.
// */
// public PositionDto() {
// this.numbers = new double[2];
// }
//
// /**
// * Simple coordinate position constructor
// *
// * @param longitude
// * @param latitude
// */
// public PositionDto(double longitude, double latitude) {
// this.numbers = new double[] { longitude, latitude };
// }
//
// /**
// * Use this constructor if you need elevation parameter
// *
// * @param longitude
// * @param latitude
// * @param elevation
// */
// public PositionDto(double longitude, double latitude, double elevation) {
// this.numbers = new double[] { longitude, latitude, elevation };
// }
//
// /**
// * Copy constructor
// *
// * @param position
// */
// public PositionDto(PositionDto position) {
// if (position != null) {
// double[] copyNumbers = position.getNumbers();
// this.numbers = new double[copyNumbers.length];
// for (int i = 0; i < copyNumbers.length; i++) {
// this.numbers[i] = copyNumbers[i];
// }
// }
// }
//
// @Override
// public String toString() {
// if (numbers == null) {
// return "null numbers[]";
// }
// StringBuilder value = new StringBuilder("[");
// for (int i = 0; i < numbers.length; i++) {
// value.append(numbers[i]);
// if (i < numbers.length - 1) {
// value.append(", ");
// }
// }
// value.append("]");
// return value.toString();
// }
//
// public void setLongitude(double longitude) {
// this.numbers[0] = longitude;
// }
//
// public double getLongitude() {
// return numbers[0];
// }
//
// public void setLatitude(double latitude) {
// this.numbers[1] = latitude;
// }
//
// public double getLatitude() {
// return numbers[1];
// }
//
// public void setElevation(double elevation) {
// this.numbers[2] = elevation;
// }
//
// public double getElevation() {
// return numbers[2];
// }
//
// public double[] getNumbers() {
// return numbers;
// }
//
// public void setNumbers(double[] numbers) {
// this.numbers = numbers;
// }
// }
//
// Path: ugeojson-model/src/main/java/org/ugeojson/model/geometry/MultiPointDto.java
// public class MultiPointDto extends GeometryDto {
//
// private static final long serialVersionUID = 1L;
//
// private List<PositionDto> positions;
//
// public List<PositionDto> getPositions() {
// return positions;
// }
//
// public void setPositions(List<PositionDto> positions) {
// this.positions = positions;
// }
//
// @Override
// public GeoJSONObjectTypeEnum getGeoJSONObjectType() {
// return GeoJSONObjectTypeEnum.MultiPoint;
// }
// }
//
// Path: ugeojson-parser/src/main/java/org/ugeojson/parser/deserializer/MultiPointDeserializer.java
// public class MultiPointDeserializer implements JsonDeserializer<MultiPointDto> {
//
// @Override
// public MultiPointDto deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) {
//
// MultiPointDto dto = new MultiPointDto();
// List<PositionDto> positions = new ArrayList<>();
// dto.setPositions(positions);
//
// JsonObject asJsonObject = json.getAsJsonObject();
// JsonArray jsonArray = asJsonObject.get("coordinates").getAsJsonArray();
// for (int i = 0; i < jsonArray.size(); i++) {
// PositionDto position = context.deserialize(jsonArray.get(i), PositionDto.class);
// positions.add(position);
// }
//
// dto.setBbox(BoundingBoxParser.parseBbox(asJsonObject, context));
//
// return dto;
// }
//
// }
//
// Path: ugeojson-parser/src/main/java/org/ugeojson/parser/deserializer/PositionDeserializer.java
// public class PositionDeserializer implements JsonDeserializer<PositionDto> {
//
// @Override
// public PositionDto deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) {
//
// JsonArray asJsonArray = json.getAsJsonArray();
// double[] numbers = new double[asJsonArray.size()];
// for (int i = 0; i < asJsonArray.size(); i++) {
// numbers[i] = asJsonArray.get(i).getAsDouble();
// }
//
// PositionDto positionDto = new PositionDto();
// positionDto.setNumbers(numbers);
// return positionDto;
// }
//
// }
// Path: ugeojson-parser/src/test/java/org/ugeojson/parser/deserializer/MultiPointDeserializerShould.java
import static org.hamcrest.CoreMatchers.equalTo;
import static org.junit.Assert.assertThat;
import org.junit.Test;
import org.ugeojson.model.PositionDto;
import org.ugeojson.model.geometry.MultiPointDto;
import org.ugeojson.parser.deserializer.MultiPointDeserializer;
import org.ugeojson.parser.deserializer.PositionDeserializer;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
package org.ugeojson.parser.deserializer;
public class MultiPointDeserializerShould {
@Test public void
deserialize_linestring(){
GsonBuilder gsonBuilder = new GsonBuilder();
gsonBuilder.registerTypeAdapter(PositionDto.class, new PositionDeserializer()); | gsonBuilder.registerTypeAdapter(MultiPointDto.class, new MultiPointDeserializer()); |
mokszr/ultimate-geojson | ugeojson-builder/src/main/java/org/ugeojson/builder/common/GeoJSONBuilder.java | // Path: ugeojson-model/src/main/java/org/ugeojson/model/BoundingBoxDto.java
// public class BoundingBoxDto implements Serializable {
//
// private static final long serialVersionUID = 1L;
//
// private PositionDto southWestCorner;
// private PositionDto northEastCorner;
//
// public PositionDto getSouthWestCorner() {
// return southWestCorner;
// }
//
// public void setSouthWestCorner(PositionDto southWestCorner) {
// this.southWestCorner = southWestCorner;
// }
//
// public PositionDto getNorthEastCorner() {
// return northEastCorner;
// }
//
// public void setNorthEastCorner(PositionDto northEastCorner) {
// this.northEastCorner = northEastCorner;
// }
//
// }
//
// Path: ugeojson-model/src/main/java/org/ugeojson/model/GeoJSONObjectDto.java
// public abstract class GeoJSONObjectDto implements Serializable {
//
// private static final long serialVersionUID = 1L;
//
// private BoundingBoxDto bbox;
//
// public abstract GeoJSONObjectTypeEnum getGeoJSONObjectType();
//
// public BoundingBoxDto getBbox() {
// return bbox;
// }
//
// public void setBbox(BoundingBoxDto bbox) {
// this.bbox = bbox;
// }
// }
//
// Path: ugeojson-model/src/main/java/org/ugeojson/model/GeoJSONObjectTypeEnum.java
// public enum GeoJSONObjectTypeEnum {
//
// Point(PointDto.class), MultiPoint(MultiPointDto.class), LineString(LineStringDto.class), MultiLineString(
// MultiLineStringDto.class), Polygon(PolygonDto.class), MultiPolygon(
// MultiPolygonDto.class), GeometryCollection(GeometryCollectionDto.class), Feature(
// FeatureDto.class), FeatureCollection(FeatureCollectionDto.class);
//
// private final Class dtoClass;
//
// private GeoJSONObjectTypeEnum(Class dtoClass) {
// this.dtoClass = dtoClass;
// }
//
// public Class getDtoClass() {
// return dtoClass;
// }
// }
//
// Path: ugeojson-model/src/main/java/org/ugeojson/model/PositionDto.java
// public class PositionDto implements Serializable {
//
// private static final long serialVersionUID = 1L;
//
// private double[] numbers;
//
// /**
// * This constructor initializes numbers field to hold two double numbers. Do
// * not use this constructor if you need the third elevation parameter.
// */
// public PositionDto() {
// this.numbers = new double[2];
// }
//
// /**
// * Simple coordinate position constructor
// *
// * @param longitude
// * @param latitude
// */
// public PositionDto(double longitude, double latitude) {
// this.numbers = new double[] { longitude, latitude };
// }
//
// /**
// * Use this constructor if you need elevation parameter
// *
// * @param longitude
// * @param latitude
// * @param elevation
// */
// public PositionDto(double longitude, double latitude, double elevation) {
// this.numbers = new double[] { longitude, latitude, elevation };
// }
//
// /**
// * Copy constructor
// *
// * @param position
// */
// public PositionDto(PositionDto position) {
// if (position != null) {
// double[] copyNumbers = position.getNumbers();
// this.numbers = new double[copyNumbers.length];
// for (int i = 0; i < copyNumbers.length; i++) {
// this.numbers[i] = copyNumbers[i];
// }
// }
// }
//
// @Override
// public String toString() {
// if (numbers == null) {
// return "null numbers[]";
// }
// StringBuilder value = new StringBuilder("[");
// for (int i = 0; i < numbers.length; i++) {
// value.append(numbers[i]);
// if (i < numbers.length - 1) {
// value.append(", ");
// }
// }
// value.append("]");
// return value.toString();
// }
//
// public void setLongitude(double longitude) {
// this.numbers[0] = longitude;
// }
//
// public double getLongitude() {
// return numbers[0];
// }
//
// public void setLatitude(double latitude) {
// this.numbers[1] = latitude;
// }
//
// public double getLatitude() {
// return numbers[1];
// }
//
// public void setElevation(double elevation) {
// this.numbers[2] = elevation;
// }
//
// public double getElevation() {
// return numbers[2];
// }
//
// public double[] getNumbers() {
// return numbers;
// }
//
// public void setNumbers(double[] numbers) {
// this.numbers = numbers;
// }
// }
| import org.ugeojson.model.BoundingBoxDto;
import org.ugeojson.model.GeoJSONObjectDto;
import org.ugeojson.model.GeoJSONObjectTypeEnum;
import org.ugeojson.model.PositionDto; | package org.ugeojson.builder.common;
/**
* @author moksuzer
*
*/
public abstract class GeoJSONBuilder<T extends GeoJSONObjectDto> {
/**
* Convert geojsonDto object to GeoJSON geometry string.
* @param geoJSONDto GeoJSONObjectDto object to be converted to GeoJSON
* @return
*/
public abstract String toGeoJSON(T geoJSONDto);
| // Path: ugeojson-model/src/main/java/org/ugeojson/model/BoundingBoxDto.java
// public class BoundingBoxDto implements Serializable {
//
// private static final long serialVersionUID = 1L;
//
// private PositionDto southWestCorner;
// private PositionDto northEastCorner;
//
// public PositionDto getSouthWestCorner() {
// return southWestCorner;
// }
//
// public void setSouthWestCorner(PositionDto southWestCorner) {
// this.southWestCorner = southWestCorner;
// }
//
// public PositionDto getNorthEastCorner() {
// return northEastCorner;
// }
//
// public void setNorthEastCorner(PositionDto northEastCorner) {
// this.northEastCorner = northEastCorner;
// }
//
// }
//
// Path: ugeojson-model/src/main/java/org/ugeojson/model/GeoJSONObjectDto.java
// public abstract class GeoJSONObjectDto implements Serializable {
//
// private static final long serialVersionUID = 1L;
//
// private BoundingBoxDto bbox;
//
// public abstract GeoJSONObjectTypeEnum getGeoJSONObjectType();
//
// public BoundingBoxDto getBbox() {
// return bbox;
// }
//
// public void setBbox(BoundingBoxDto bbox) {
// this.bbox = bbox;
// }
// }
//
// Path: ugeojson-model/src/main/java/org/ugeojson/model/GeoJSONObjectTypeEnum.java
// public enum GeoJSONObjectTypeEnum {
//
// Point(PointDto.class), MultiPoint(MultiPointDto.class), LineString(LineStringDto.class), MultiLineString(
// MultiLineStringDto.class), Polygon(PolygonDto.class), MultiPolygon(
// MultiPolygonDto.class), GeometryCollection(GeometryCollectionDto.class), Feature(
// FeatureDto.class), FeatureCollection(FeatureCollectionDto.class);
//
// private final Class dtoClass;
//
// private GeoJSONObjectTypeEnum(Class dtoClass) {
// this.dtoClass = dtoClass;
// }
//
// public Class getDtoClass() {
// return dtoClass;
// }
// }
//
// Path: ugeojson-model/src/main/java/org/ugeojson/model/PositionDto.java
// public class PositionDto implements Serializable {
//
// private static final long serialVersionUID = 1L;
//
// private double[] numbers;
//
// /**
// * This constructor initializes numbers field to hold two double numbers. Do
// * not use this constructor if you need the third elevation parameter.
// */
// public PositionDto() {
// this.numbers = new double[2];
// }
//
// /**
// * Simple coordinate position constructor
// *
// * @param longitude
// * @param latitude
// */
// public PositionDto(double longitude, double latitude) {
// this.numbers = new double[] { longitude, latitude };
// }
//
// /**
// * Use this constructor if you need elevation parameter
// *
// * @param longitude
// * @param latitude
// * @param elevation
// */
// public PositionDto(double longitude, double latitude, double elevation) {
// this.numbers = new double[] { longitude, latitude, elevation };
// }
//
// /**
// * Copy constructor
// *
// * @param position
// */
// public PositionDto(PositionDto position) {
// if (position != null) {
// double[] copyNumbers = position.getNumbers();
// this.numbers = new double[copyNumbers.length];
// for (int i = 0; i < copyNumbers.length; i++) {
// this.numbers[i] = copyNumbers[i];
// }
// }
// }
//
// @Override
// public String toString() {
// if (numbers == null) {
// return "null numbers[]";
// }
// StringBuilder value = new StringBuilder("[");
// for (int i = 0; i < numbers.length; i++) {
// value.append(numbers[i]);
// if (i < numbers.length - 1) {
// value.append(", ");
// }
// }
// value.append("]");
// return value.toString();
// }
//
// public void setLongitude(double longitude) {
// this.numbers[0] = longitude;
// }
//
// public double getLongitude() {
// return numbers[0];
// }
//
// public void setLatitude(double latitude) {
// this.numbers[1] = latitude;
// }
//
// public double getLatitude() {
// return numbers[1];
// }
//
// public void setElevation(double elevation) {
// this.numbers[2] = elevation;
// }
//
// public double getElevation() {
// return numbers[2];
// }
//
// public double[] getNumbers() {
// return numbers;
// }
//
// public void setNumbers(double[] numbers) {
// this.numbers = numbers;
// }
// }
// Path: ugeojson-builder/src/main/java/org/ugeojson/builder/common/GeoJSONBuilder.java
import org.ugeojson.model.BoundingBoxDto;
import org.ugeojson.model.GeoJSONObjectDto;
import org.ugeojson.model.GeoJSONObjectTypeEnum;
import org.ugeojson.model.PositionDto;
package org.ugeojson.builder.common;
/**
* @author moksuzer
*
*/
public abstract class GeoJSONBuilder<T extends GeoJSONObjectDto> {
/**
* Convert geojsonDto object to GeoJSON geometry string.
* @param geoJSONDto GeoJSONObjectDto object to be converted to GeoJSON
* @return
*/
public abstract String toGeoJSON(T geoJSONDto);
| protected void buildTypePart(StringBuilder builder, GeoJSONObjectTypeEnum type) { |
mokszr/ultimate-geojson | ugeojson-model/src/main/java/org/ugeojson/model/feature/FeatureDto.java | // Path: ugeojson-model/src/main/java/org/ugeojson/model/GeoJSONObjectDto.java
// public abstract class GeoJSONObjectDto implements Serializable {
//
// private static final long serialVersionUID = 1L;
//
// private BoundingBoxDto bbox;
//
// public abstract GeoJSONObjectTypeEnum getGeoJSONObjectType();
//
// public BoundingBoxDto getBbox() {
// return bbox;
// }
//
// public void setBbox(BoundingBoxDto bbox) {
// this.bbox = bbox;
// }
// }
//
// Path: ugeojson-model/src/main/java/org/ugeojson/model/GeoJSONObjectTypeEnum.java
// public enum GeoJSONObjectTypeEnum {
//
// Point(PointDto.class), MultiPoint(MultiPointDto.class), LineString(LineStringDto.class), MultiLineString(
// MultiLineStringDto.class), Polygon(PolygonDto.class), MultiPolygon(
// MultiPolygonDto.class), GeometryCollection(GeometryCollectionDto.class), Feature(
// FeatureDto.class), FeatureCollection(FeatureCollectionDto.class);
//
// private final Class dtoClass;
//
// private GeoJSONObjectTypeEnum(Class dtoClass) {
// this.dtoClass = dtoClass;
// }
//
// public Class getDtoClass() {
// return dtoClass;
// }
// }
//
// Path: ugeojson-model/src/main/java/org/ugeojson/model/geometry/GeometryDto.java
// public abstract class GeometryDto extends GeoJSONObjectDto {
//
// private static final long serialVersionUID = 1L;
//
// }
| import org.ugeojson.model.GeoJSONObjectDto;
import org.ugeojson.model.GeoJSONObjectTypeEnum;
import org.ugeojson.model.geometry.GeometryDto; | package org.ugeojson.model.feature;
/**
* @author moksuzer
*
*/
public class FeatureDto extends GeoJSONObjectDto {
private static final long serialVersionUID = 1L;
| // Path: ugeojson-model/src/main/java/org/ugeojson/model/GeoJSONObjectDto.java
// public abstract class GeoJSONObjectDto implements Serializable {
//
// private static final long serialVersionUID = 1L;
//
// private BoundingBoxDto bbox;
//
// public abstract GeoJSONObjectTypeEnum getGeoJSONObjectType();
//
// public BoundingBoxDto getBbox() {
// return bbox;
// }
//
// public void setBbox(BoundingBoxDto bbox) {
// this.bbox = bbox;
// }
// }
//
// Path: ugeojson-model/src/main/java/org/ugeojson/model/GeoJSONObjectTypeEnum.java
// public enum GeoJSONObjectTypeEnum {
//
// Point(PointDto.class), MultiPoint(MultiPointDto.class), LineString(LineStringDto.class), MultiLineString(
// MultiLineStringDto.class), Polygon(PolygonDto.class), MultiPolygon(
// MultiPolygonDto.class), GeometryCollection(GeometryCollectionDto.class), Feature(
// FeatureDto.class), FeatureCollection(FeatureCollectionDto.class);
//
// private final Class dtoClass;
//
// private GeoJSONObjectTypeEnum(Class dtoClass) {
// this.dtoClass = dtoClass;
// }
//
// public Class getDtoClass() {
// return dtoClass;
// }
// }
//
// Path: ugeojson-model/src/main/java/org/ugeojson/model/geometry/GeometryDto.java
// public abstract class GeometryDto extends GeoJSONObjectDto {
//
// private static final long serialVersionUID = 1L;
//
// }
// Path: ugeojson-model/src/main/java/org/ugeojson/model/feature/FeatureDto.java
import org.ugeojson.model.GeoJSONObjectDto;
import org.ugeojson.model.GeoJSONObjectTypeEnum;
import org.ugeojson.model.geometry.GeometryDto;
package org.ugeojson.model.feature;
/**
* @author moksuzer
*
*/
public class FeatureDto extends GeoJSONObjectDto {
private static final long serialVersionUID = 1L;
| private GeometryDto geometry; |
mokszr/ultimate-geojson | ugeojson-model/src/main/java/org/ugeojson/model/feature/FeatureDto.java | // Path: ugeojson-model/src/main/java/org/ugeojson/model/GeoJSONObjectDto.java
// public abstract class GeoJSONObjectDto implements Serializable {
//
// private static final long serialVersionUID = 1L;
//
// private BoundingBoxDto bbox;
//
// public abstract GeoJSONObjectTypeEnum getGeoJSONObjectType();
//
// public BoundingBoxDto getBbox() {
// return bbox;
// }
//
// public void setBbox(BoundingBoxDto bbox) {
// this.bbox = bbox;
// }
// }
//
// Path: ugeojson-model/src/main/java/org/ugeojson/model/GeoJSONObjectTypeEnum.java
// public enum GeoJSONObjectTypeEnum {
//
// Point(PointDto.class), MultiPoint(MultiPointDto.class), LineString(LineStringDto.class), MultiLineString(
// MultiLineStringDto.class), Polygon(PolygonDto.class), MultiPolygon(
// MultiPolygonDto.class), GeometryCollection(GeometryCollectionDto.class), Feature(
// FeatureDto.class), FeatureCollection(FeatureCollectionDto.class);
//
// private final Class dtoClass;
//
// private GeoJSONObjectTypeEnum(Class dtoClass) {
// this.dtoClass = dtoClass;
// }
//
// public Class getDtoClass() {
// return dtoClass;
// }
// }
//
// Path: ugeojson-model/src/main/java/org/ugeojson/model/geometry/GeometryDto.java
// public abstract class GeometryDto extends GeoJSONObjectDto {
//
// private static final long serialVersionUID = 1L;
//
// }
| import org.ugeojson.model.GeoJSONObjectDto;
import org.ugeojson.model.GeoJSONObjectTypeEnum;
import org.ugeojson.model.geometry.GeometryDto; | package org.ugeojson.model.feature;
/**
* @author moksuzer
*
*/
public class FeatureDto extends GeoJSONObjectDto {
private static final long serialVersionUID = 1L;
private GeometryDto geometry;
private String properties;
private String id;
@Override | // Path: ugeojson-model/src/main/java/org/ugeojson/model/GeoJSONObjectDto.java
// public abstract class GeoJSONObjectDto implements Serializable {
//
// private static final long serialVersionUID = 1L;
//
// private BoundingBoxDto bbox;
//
// public abstract GeoJSONObjectTypeEnum getGeoJSONObjectType();
//
// public BoundingBoxDto getBbox() {
// return bbox;
// }
//
// public void setBbox(BoundingBoxDto bbox) {
// this.bbox = bbox;
// }
// }
//
// Path: ugeojson-model/src/main/java/org/ugeojson/model/GeoJSONObjectTypeEnum.java
// public enum GeoJSONObjectTypeEnum {
//
// Point(PointDto.class), MultiPoint(MultiPointDto.class), LineString(LineStringDto.class), MultiLineString(
// MultiLineStringDto.class), Polygon(PolygonDto.class), MultiPolygon(
// MultiPolygonDto.class), GeometryCollection(GeometryCollectionDto.class), Feature(
// FeatureDto.class), FeatureCollection(FeatureCollectionDto.class);
//
// private final Class dtoClass;
//
// private GeoJSONObjectTypeEnum(Class dtoClass) {
// this.dtoClass = dtoClass;
// }
//
// public Class getDtoClass() {
// return dtoClass;
// }
// }
//
// Path: ugeojson-model/src/main/java/org/ugeojson/model/geometry/GeometryDto.java
// public abstract class GeometryDto extends GeoJSONObjectDto {
//
// private static final long serialVersionUID = 1L;
//
// }
// Path: ugeojson-model/src/main/java/org/ugeojson/model/feature/FeatureDto.java
import org.ugeojson.model.GeoJSONObjectDto;
import org.ugeojson.model.GeoJSONObjectTypeEnum;
import org.ugeojson.model.geometry.GeometryDto;
package org.ugeojson.model.feature;
/**
* @author moksuzer
*
*/
public class FeatureDto extends GeoJSONObjectDto {
private static final long serialVersionUID = 1L;
private GeometryDto geometry;
private String properties;
private String id;
@Override | public GeoJSONObjectTypeEnum getGeoJSONObjectType() { |
mokszr/ultimate-geojson | ugeojson-parser/src/test/java/org/ugeojson/parser/deserializer/PositionDeserializerShould.java | // Path: ugeojson-model/src/main/java/org/ugeojson/model/PositionDto.java
// public class PositionDto implements Serializable {
//
// private static final long serialVersionUID = 1L;
//
// private double[] numbers;
//
// /**
// * This constructor initializes numbers field to hold two double numbers. Do
// * not use this constructor if you need the third elevation parameter.
// */
// public PositionDto() {
// this.numbers = new double[2];
// }
//
// /**
// * Simple coordinate position constructor
// *
// * @param longitude
// * @param latitude
// */
// public PositionDto(double longitude, double latitude) {
// this.numbers = new double[] { longitude, latitude };
// }
//
// /**
// * Use this constructor if you need elevation parameter
// *
// * @param longitude
// * @param latitude
// * @param elevation
// */
// public PositionDto(double longitude, double latitude, double elevation) {
// this.numbers = new double[] { longitude, latitude, elevation };
// }
//
// /**
// * Copy constructor
// *
// * @param position
// */
// public PositionDto(PositionDto position) {
// if (position != null) {
// double[] copyNumbers = position.getNumbers();
// this.numbers = new double[copyNumbers.length];
// for (int i = 0; i < copyNumbers.length; i++) {
// this.numbers[i] = copyNumbers[i];
// }
// }
// }
//
// @Override
// public String toString() {
// if (numbers == null) {
// return "null numbers[]";
// }
// StringBuilder value = new StringBuilder("[");
// for (int i = 0; i < numbers.length; i++) {
// value.append(numbers[i]);
// if (i < numbers.length - 1) {
// value.append(", ");
// }
// }
// value.append("]");
// return value.toString();
// }
//
// public void setLongitude(double longitude) {
// this.numbers[0] = longitude;
// }
//
// public double getLongitude() {
// return numbers[0];
// }
//
// public void setLatitude(double latitude) {
// this.numbers[1] = latitude;
// }
//
// public double getLatitude() {
// return numbers[1];
// }
//
// public void setElevation(double elevation) {
// this.numbers[2] = elevation;
// }
//
// public double getElevation() {
// return numbers[2];
// }
//
// public double[] getNumbers() {
// return numbers;
// }
//
// public void setNumbers(double[] numbers) {
// this.numbers = numbers;
// }
// }
//
// Path: ugeojson-parser/src/main/java/org/ugeojson/parser/deserializer/PositionDeserializer.java
// public class PositionDeserializer implements JsonDeserializer<PositionDto> {
//
// @Override
// public PositionDto deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) {
//
// JsonArray asJsonArray = json.getAsJsonArray();
// double[] numbers = new double[asJsonArray.size()];
// for (int i = 0; i < asJsonArray.size(); i++) {
// numbers[i] = asJsonArray.get(i).getAsDouble();
// }
//
// PositionDto positionDto = new PositionDto();
// positionDto.setNumbers(numbers);
// return positionDto;
// }
//
// }
| import static org.hamcrest.CoreMatchers.equalTo;
import static org.junit.Assert.assertThat;
import java.lang.reflect.Type;
import java.util.List;
import org.junit.Test;
import org.ugeojson.model.PositionDto;
import org.ugeojson.parser.deserializer.PositionDeserializer;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.google.gson.reflect.TypeToken; | package org.ugeojson.parser.deserializer;
public class PositionDeserializerShould {
@Test public void
deserialize_position(){
GsonBuilder gsonBuilder = new GsonBuilder(); | // Path: ugeojson-model/src/main/java/org/ugeojson/model/PositionDto.java
// public class PositionDto implements Serializable {
//
// private static final long serialVersionUID = 1L;
//
// private double[] numbers;
//
// /**
// * This constructor initializes numbers field to hold two double numbers. Do
// * not use this constructor if you need the third elevation parameter.
// */
// public PositionDto() {
// this.numbers = new double[2];
// }
//
// /**
// * Simple coordinate position constructor
// *
// * @param longitude
// * @param latitude
// */
// public PositionDto(double longitude, double latitude) {
// this.numbers = new double[] { longitude, latitude };
// }
//
// /**
// * Use this constructor if you need elevation parameter
// *
// * @param longitude
// * @param latitude
// * @param elevation
// */
// public PositionDto(double longitude, double latitude, double elevation) {
// this.numbers = new double[] { longitude, latitude, elevation };
// }
//
// /**
// * Copy constructor
// *
// * @param position
// */
// public PositionDto(PositionDto position) {
// if (position != null) {
// double[] copyNumbers = position.getNumbers();
// this.numbers = new double[copyNumbers.length];
// for (int i = 0; i < copyNumbers.length; i++) {
// this.numbers[i] = copyNumbers[i];
// }
// }
// }
//
// @Override
// public String toString() {
// if (numbers == null) {
// return "null numbers[]";
// }
// StringBuilder value = new StringBuilder("[");
// for (int i = 0; i < numbers.length; i++) {
// value.append(numbers[i]);
// if (i < numbers.length - 1) {
// value.append(", ");
// }
// }
// value.append("]");
// return value.toString();
// }
//
// public void setLongitude(double longitude) {
// this.numbers[0] = longitude;
// }
//
// public double getLongitude() {
// return numbers[0];
// }
//
// public void setLatitude(double latitude) {
// this.numbers[1] = latitude;
// }
//
// public double getLatitude() {
// return numbers[1];
// }
//
// public void setElevation(double elevation) {
// this.numbers[2] = elevation;
// }
//
// public double getElevation() {
// return numbers[2];
// }
//
// public double[] getNumbers() {
// return numbers;
// }
//
// public void setNumbers(double[] numbers) {
// this.numbers = numbers;
// }
// }
//
// Path: ugeojson-parser/src/main/java/org/ugeojson/parser/deserializer/PositionDeserializer.java
// public class PositionDeserializer implements JsonDeserializer<PositionDto> {
//
// @Override
// public PositionDto deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) {
//
// JsonArray asJsonArray = json.getAsJsonArray();
// double[] numbers = new double[asJsonArray.size()];
// for (int i = 0; i < asJsonArray.size(); i++) {
// numbers[i] = asJsonArray.get(i).getAsDouble();
// }
//
// PositionDto positionDto = new PositionDto();
// positionDto.setNumbers(numbers);
// return positionDto;
// }
//
// }
// Path: ugeojson-parser/src/test/java/org/ugeojson/parser/deserializer/PositionDeserializerShould.java
import static org.hamcrest.CoreMatchers.equalTo;
import static org.junit.Assert.assertThat;
import java.lang.reflect.Type;
import java.util.List;
import org.junit.Test;
import org.ugeojson.model.PositionDto;
import org.ugeojson.parser.deserializer.PositionDeserializer;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.google.gson.reflect.TypeToken;
package org.ugeojson.parser.deserializer;
public class PositionDeserializerShould {
@Test public void
deserialize_position(){
GsonBuilder gsonBuilder = new GsonBuilder(); | gsonBuilder.registerTypeAdapter(PositionDto.class, new PositionDeserializer()); |
mokszr/ultimate-geojson | ugeojson-parser/src/test/java/org/ugeojson/parser/deserializer/PositionDeserializerShould.java | // Path: ugeojson-model/src/main/java/org/ugeojson/model/PositionDto.java
// public class PositionDto implements Serializable {
//
// private static final long serialVersionUID = 1L;
//
// private double[] numbers;
//
// /**
// * This constructor initializes numbers field to hold two double numbers. Do
// * not use this constructor if you need the third elevation parameter.
// */
// public PositionDto() {
// this.numbers = new double[2];
// }
//
// /**
// * Simple coordinate position constructor
// *
// * @param longitude
// * @param latitude
// */
// public PositionDto(double longitude, double latitude) {
// this.numbers = new double[] { longitude, latitude };
// }
//
// /**
// * Use this constructor if you need elevation parameter
// *
// * @param longitude
// * @param latitude
// * @param elevation
// */
// public PositionDto(double longitude, double latitude, double elevation) {
// this.numbers = new double[] { longitude, latitude, elevation };
// }
//
// /**
// * Copy constructor
// *
// * @param position
// */
// public PositionDto(PositionDto position) {
// if (position != null) {
// double[] copyNumbers = position.getNumbers();
// this.numbers = new double[copyNumbers.length];
// for (int i = 0; i < copyNumbers.length; i++) {
// this.numbers[i] = copyNumbers[i];
// }
// }
// }
//
// @Override
// public String toString() {
// if (numbers == null) {
// return "null numbers[]";
// }
// StringBuilder value = new StringBuilder("[");
// for (int i = 0; i < numbers.length; i++) {
// value.append(numbers[i]);
// if (i < numbers.length - 1) {
// value.append(", ");
// }
// }
// value.append("]");
// return value.toString();
// }
//
// public void setLongitude(double longitude) {
// this.numbers[0] = longitude;
// }
//
// public double getLongitude() {
// return numbers[0];
// }
//
// public void setLatitude(double latitude) {
// this.numbers[1] = latitude;
// }
//
// public double getLatitude() {
// return numbers[1];
// }
//
// public void setElevation(double elevation) {
// this.numbers[2] = elevation;
// }
//
// public double getElevation() {
// return numbers[2];
// }
//
// public double[] getNumbers() {
// return numbers;
// }
//
// public void setNumbers(double[] numbers) {
// this.numbers = numbers;
// }
// }
//
// Path: ugeojson-parser/src/main/java/org/ugeojson/parser/deserializer/PositionDeserializer.java
// public class PositionDeserializer implements JsonDeserializer<PositionDto> {
//
// @Override
// public PositionDto deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) {
//
// JsonArray asJsonArray = json.getAsJsonArray();
// double[] numbers = new double[asJsonArray.size()];
// for (int i = 0; i < asJsonArray.size(); i++) {
// numbers[i] = asJsonArray.get(i).getAsDouble();
// }
//
// PositionDto positionDto = new PositionDto();
// positionDto.setNumbers(numbers);
// return positionDto;
// }
//
// }
| import static org.hamcrest.CoreMatchers.equalTo;
import static org.junit.Assert.assertThat;
import java.lang.reflect.Type;
import java.util.List;
import org.junit.Test;
import org.ugeojson.model.PositionDto;
import org.ugeojson.parser.deserializer.PositionDeserializer;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.google.gson.reflect.TypeToken; | package org.ugeojson.parser.deserializer;
public class PositionDeserializerShould {
@Test public void
deserialize_position(){
GsonBuilder gsonBuilder = new GsonBuilder(); | // Path: ugeojson-model/src/main/java/org/ugeojson/model/PositionDto.java
// public class PositionDto implements Serializable {
//
// private static final long serialVersionUID = 1L;
//
// private double[] numbers;
//
// /**
// * This constructor initializes numbers field to hold two double numbers. Do
// * not use this constructor if you need the third elevation parameter.
// */
// public PositionDto() {
// this.numbers = new double[2];
// }
//
// /**
// * Simple coordinate position constructor
// *
// * @param longitude
// * @param latitude
// */
// public PositionDto(double longitude, double latitude) {
// this.numbers = new double[] { longitude, latitude };
// }
//
// /**
// * Use this constructor if you need elevation parameter
// *
// * @param longitude
// * @param latitude
// * @param elevation
// */
// public PositionDto(double longitude, double latitude, double elevation) {
// this.numbers = new double[] { longitude, latitude, elevation };
// }
//
// /**
// * Copy constructor
// *
// * @param position
// */
// public PositionDto(PositionDto position) {
// if (position != null) {
// double[] copyNumbers = position.getNumbers();
// this.numbers = new double[copyNumbers.length];
// for (int i = 0; i < copyNumbers.length; i++) {
// this.numbers[i] = copyNumbers[i];
// }
// }
// }
//
// @Override
// public String toString() {
// if (numbers == null) {
// return "null numbers[]";
// }
// StringBuilder value = new StringBuilder("[");
// for (int i = 0; i < numbers.length; i++) {
// value.append(numbers[i]);
// if (i < numbers.length - 1) {
// value.append(", ");
// }
// }
// value.append("]");
// return value.toString();
// }
//
// public void setLongitude(double longitude) {
// this.numbers[0] = longitude;
// }
//
// public double getLongitude() {
// return numbers[0];
// }
//
// public void setLatitude(double latitude) {
// this.numbers[1] = latitude;
// }
//
// public double getLatitude() {
// return numbers[1];
// }
//
// public void setElevation(double elevation) {
// this.numbers[2] = elevation;
// }
//
// public double getElevation() {
// return numbers[2];
// }
//
// public double[] getNumbers() {
// return numbers;
// }
//
// public void setNumbers(double[] numbers) {
// this.numbers = numbers;
// }
// }
//
// Path: ugeojson-parser/src/main/java/org/ugeojson/parser/deserializer/PositionDeserializer.java
// public class PositionDeserializer implements JsonDeserializer<PositionDto> {
//
// @Override
// public PositionDto deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) {
//
// JsonArray asJsonArray = json.getAsJsonArray();
// double[] numbers = new double[asJsonArray.size()];
// for (int i = 0; i < asJsonArray.size(); i++) {
// numbers[i] = asJsonArray.get(i).getAsDouble();
// }
//
// PositionDto positionDto = new PositionDto();
// positionDto.setNumbers(numbers);
// return positionDto;
// }
//
// }
// Path: ugeojson-parser/src/test/java/org/ugeojson/parser/deserializer/PositionDeserializerShould.java
import static org.hamcrest.CoreMatchers.equalTo;
import static org.junit.Assert.assertThat;
import java.lang.reflect.Type;
import java.util.List;
import org.junit.Test;
import org.ugeojson.model.PositionDto;
import org.ugeojson.parser.deserializer.PositionDeserializer;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.google.gson.reflect.TypeToken;
package org.ugeojson.parser.deserializer;
public class PositionDeserializerShould {
@Test public void
deserialize_position(){
GsonBuilder gsonBuilder = new GsonBuilder(); | gsonBuilder.registerTypeAdapter(PositionDto.class, new PositionDeserializer()); |
mokszr/ultimate-geojson | ugeojson-builder/src/main/java/org/ugeojson/builder/geometry/LineStringBuilder.java | // Path: ugeojson-builder/src/main/java/org/ugeojson/builder/common/BuilderConstants.java
// public interface BuilderConstants {
//
// public static final String OPEN_BRACKET = "[";
// public static final String CLOSE_BRACKET = "]";
// public static final String OPEN_CURLY_BRACE = "{";
// public static final String CLOSE_CURLY_BRACE = "}";
//
// public static final String COMMA_SPACE = ", ";
// public static final String COMMA = ",";
// public static final String SPACE = " ";
// public static final String COMMA_NEWLINE = ",\n";
// public static final String NEWLINE = "\n";
// public static final String DOUBLE_QUOTE = "\"";
// public static final String NULL_VALUE = "null";
// public static final String TAB_SPACE = " ";
// public static final String EMPTY = "";
//
// public static final String TYPE_SPACE = "\"type\": ";
// public static final String COORDINATES_SPACE = "\"coordinates\": ";
// public static final String GEOMETRIES_SPACE = "\"geometries\": ";
// public static final String GEOMETRY_SPACE = "\"geometry\": ";
// public static final String PROPERTIES_SPACE = "\"properties\": ";
// public static final String ID_SPACE = "\"id\": ";
// public static final String FEATURES_SPACE = "\"features\": ";
// public static final String BBOX_SPACE = "\"bbox\": ";
// }
//
// Path: ugeojson-model/src/main/java/org/ugeojson/model/GeoJSONObjectTypeEnum.java
// public enum GeoJSONObjectTypeEnum {
//
// Point(PointDto.class), MultiPoint(MultiPointDto.class), LineString(LineStringDto.class), MultiLineString(
// MultiLineStringDto.class), Polygon(PolygonDto.class), MultiPolygon(
// MultiPolygonDto.class), GeometryCollection(GeometryCollectionDto.class), Feature(
// FeatureDto.class), FeatureCollection(FeatureCollectionDto.class);
//
// private final Class dtoClass;
//
// private GeoJSONObjectTypeEnum(Class dtoClass) {
// this.dtoClass = dtoClass;
// }
//
// public Class getDtoClass() {
// return dtoClass;
// }
// }
//
// Path: ugeojson-model/src/main/java/org/ugeojson/model/geometry/LineStringDto.java
// public class LineStringDto extends GeometryDto {
//
// private static final long serialVersionUID = 1L;
//
// private List<PositionDto> positions;
//
// public LineStringDto(){
// }
//
// public LineStringDto(List<PositionDto> positions){
// this.positions = new ArrayList<>();
// for (PositionDto positionDto : positions) {
// this.positions.add(new PositionDto(positionDto));
// }
// }
//
// public List<PositionDto> getPositions() {
// return positions;
// }
//
// public void setPositions(List<PositionDto> positions) {
// this.positions = positions;
// }
//
// @Override
// public GeoJSONObjectTypeEnum getGeoJSONObjectType() {
// return GeoJSONObjectTypeEnum.LineString;
// }
// }
| import org.ugeojson.builder.common.BuilderConstants;
import org.ugeojson.model.GeoJSONObjectTypeEnum;
import org.ugeojson.model.geometry.LineStringDto; | package org.ugeojson.builder.geometry;
/**
* @author moksuzer
*
*/
public class LineStringBuilder extends GeometryBuilder<LineStringDto> {
private static final LineStringBuilder INSTANCE = new LineStringBuilder();
public static LineStringBuilder getInstance() {
return INSTANCE;
}
private LineStringBuilder() {
}
@Override
public String toGeoJSON(LineStringDto lineString) {
if (lineString == null || lineString.getPositions() == null || lineString.getPositions().isEmpty()) { | // Path: ugeojson-builder/src/main/java/org/ugeojson/builder/common/BuilderConstants.java
// public interface BuilderConstants {
//
// public static final String OPEN_BRACKET = "[";
// public static final String CLOSE_BRACKET = "]";
// public static final String OPEN_CURLY_BRACE = "{";
// public static final String CLOSE_CURLY_BRACE = "}";
//
// public static final String COMMA_SPACE = ", ";
// public static final String COMMA = ",";
// public static final String SPACE = " ";
// public static final String COMMA_NEWLINE = ",\n";
// public static final String NEWLINE = "\n";
// public static final String DOUBLE_QUOTE = "\"";
// public static final String NULL_VALUE = "null";
// public static final String TAB_SPACE = " ";
// public static final String EMPTY = "";
//
// public static final String TYPE_SPACE = "\"type\": ";
// public static final String COORDINATES_SPACE = "\"coordinates\": ";
// public static final String GEOMETRIES_SPACE = "\"geometries\": ";
// public static final String GEOMETRY_SPACE = "\"geometry\": ";
// public static final String PROPERTIES_SPACE = "\"properties\": ";
// public static final String ID_SPACE = "\"id\": ";
// public static final String FEATURES_SPACE = "\"features\": ";
// public static final String BBOX_SPACE = "\"bbox\": ";
// }
//
// Path: ugeojson-model/src/main/java/org/ugeojson/model/GeoJSONObjectTypeEnum.java
// public enum GeoJSONObjectTypeEnum {
//
// Point(PointDto.class), MultiPoint(MultiPointDto.class), LineString(LineStringDto.class), MultiLineString(
// MultiLineStringDto.class), Polygon(PolygonDto.class), MultiPolygon(
// MultiPolygonDto.class), GeometryCollection(GeometryCollectionDto.class), Feature(
// FeatureDto.class), FeatureCollection(FeatureCollectionDto.class);
//
// private final Class dtoClass;
//
// private GeoJSONObjectTypeEnum(Class dtoClass) {
// this.dtoClass = dtoClass;
// }
//
// public Class getDtoClass() {
// return dtoClass;
// }
// }
//
// Path: ugeojson-model/src/main/java/org/ugeojson/model/geometry/LineStringDto.java
// public class LineStringDto extends GeometryDto {
//
// private static final long serialVersionUID = 1L;
//
// private List<PositionDto> positions;
//
// public LineStringDto(){
// }
//
// public LineStringDto(List<PositionDto> positions){
// this.positions = new ArrayList<>();
// for (PositionDto positionDto : positions) {
// this.positions.add(new PositionDto(positionDto));
// }
// }
//
// public List<PositionDto> getPositions() {
// return positions;
// }
//
// public void setPositions(List<PositionDto> positions) {
// this.positions = positions;
// }
//
// @Override
// public GeoJSONObjectTypeEnum getGeoJSONObjectType() {
// return GeoJSONObjectTypeEnum.LineString;
// }
// }
// Path: ugeojson-builder/src/main/java/org/ugeojson/builder/geometry/LineStringBuilder.java
import org.ugeojson.builder.common.BuilderConstants;
import org.ugeojson.model.GeoJSONObjectTypeEnum;
import org.ugeojson.model.geometry.LineStringDto;
package org.ugeojson.builder.geometry;
/**
* @author moksuzer
*
*/
public class LineStringBuilder extends GeometryBuilder<LineStringDto> {
private static final LineStringBuilder INSTANCE = new LineStringBuilder();
public static LineStringBuilder getInstance() {
return INSTANCE;
}
private LineStringBuilder() {
}
@Override
public String toGeoJSON(LineStringDto lineString) {
if (lineString == null || lineString.getPositions() == null || lineString.getPositions().isEmpty()) { | return BuilderConstants.NULL_VALUE; |
mokszr/ultimate-geojson | ugeojson-builder/src/main/java/org/ugeojson/builder/geometry/LineStringBuilder.java | // Path: ugeojson-builder/src/main/java/org/ugeojson/builder/common/BuilderConstants.java
// public interface BuilderConstants {
//
// public static final String OPEN_BRACKET = "[";
// public static final String CLOSE_BRACKET = "]";
// public static final String OPEN_CURLY_BRACE = "{";
// public static final String CLOSE_CURLY_BRACE = "}";
//
// public static final String COMMA_SPACE = ", ";
// public static final String COMMA = ",";
// public static final String SPACE = " ";
// public static final String COMMA_NEWLINE = ",\n";
// public static final String NEWLINE = "\n";
// public static final String DOUBLE_QUOTE = "\"";
// public static final String NULL_VALUE = "null";
// public static final String TAB_SPACE = " ";
// public static final String EMPTY = "";
//
// public static final String TYPE_SPACE = "\"type\": ";
// public static final String COORDINATES_SPACE = "\"coordinates\": ";
// public static final String GEOMETRIES_SPACE = "\"geometries\": ";
// public static final String GEOMETRY_SPACE = "\"geometry\": ";
// public static final String PROPERTIES_SPACE = "\"properties\": ";
// public static final String ID_SPACE = "\"id\": ";
// public static final String FEATURES_SPACE = "\"features\": ";
// public static final String BBOX_SPACE = "\"bbox\": ";
// }
//
// Path: ugeojson-model/src/main/java/org/ugeojson/model/GeoJSONObjectTypeEnum.java
// public enum GeoJSONObjectTypeEnum {
//
// Point(PointDto.class), MultiPoint(MultiPointDto.class), LineString(LineStringDto.class), MultiLineString(
// MultiLineStringDto.class), Polygon(PolygonDto.class), MultiPolygon(
// MultiPolygonDto.class), GeometryCollection(GeometryCollectionDto.class), Feature(
// FeatureDto.class), FeatureCollection(FeatureCollectionDto.class);
//
// private final Class dtoClass;
//
// private GeoJSONObjectTypeEnum(Class dtoClass) {
// this.dtoClass = dtoClass;
// }
//
// public Class getDtoClass() {
// return dtoClass;
// }
// }
//
// Path: ugeojson-model/src/main/java/org/ugeojson/model/geometry/LineStringDto.java
// public class LineStringDto extends GeometryDto {
//
// private static final long serialVersionUID = 1L;
//
// private List<PositionDto> positions;
//
// public LineStringDto(){
// }
//
// public LineStringDto(List<PositionDto> positions){
// this.positions = new ArrayList<>();
// for (PositionDto positionDto : positions) {
// this.positions.add(new PositionDto(positionDto));
// }
// }
//
// public List<PositionDto> getPositions() {
// return positions;
// }
//
// public void setPositions(List<PositionDto> positions) {
// this.positions = positions;
// }
//
// @Override
// public GeoJSONObjectTypeEnum getGeoJSONObjectType() {
// return GeoJSONObjectTypeEnum.LineString;
// }
// }
| import org.ugeojson.builder.common.BuilderConstants;
import org.ugeojson.model.GeoJSONObjectTypeEnum;
import org.ugeojson.model.geometry.LineStringDto; | package org.ugeojson.builder.geometry;
/**
* @author moksuzer
*
*/
public class LineStringBuilder extends GeometryBuilder<LineStringDto> {
private static final LineStringBuilder INSTANCE = new LineStringBuilder();
public static LineStringBuilder getInstance() {
return INSTANCE;
}
private LineStringBuilder() {
}
@Override
public String toGeoJSON(LineStringDto lineString) {
if (lineString == null || lineString.getPositions() == null || lineString.getPositions().isEmpty()) {
return BuilderConstants.NULL_VALUE;
}
StringBuilder builder = initializeBuilder(); | // Path: ugeojson-builder/src/main/java/org/ugeojson/builder/common/BuilderConstants.java
// public interface BuilderConstants {
//
// public static final String OPEN_BRACKET = "[";
// public static final String CLOSE_BRACKET = "]";
// public static final String OPEN_CURLY_BRACE = "{";
// public static final String CLOSE_CURLY_BRACE = "}";
//
// public static final String COMMA_SPACE = ", ";
// public static final String COMMA = ",";
// public static final String SPACE = " ";
// public static final String COMMA_NEWLINE = ",\n";
// public static final String NEWLINE = "\n";
// public static final String DOUBLE_QUOTE = "\"";
// public static final String NULL_VALUE = "null";
// public static final String TAB_SPACE = " ";
// public static final String EMPTY = "";
//
// public static final String TYPE_SPACE = "\"type\": ";
// public static final String COORDINATES_SPACE = "\"coordinates\": ";
// public static final String GEOMETRIES_SPACE = "\"geometries\": ";
// public static final String GEOMETRY_SPACE = "\"geometry\": ";
// public static final String PROPERTIES_SPACE = "\"properties\": ";
// public static final String ID_SPACE = "\"id\": ";
// public static final String FEATURES_SPACE = "\"features\": ";
// public static final String BBOX_SPACE = "\"bbox\": ";
// }
//
// Path: ugeojson-model/src/main/java/org/ugeojson/model/GeoJSONObjectTypeEnum.java
// public enum GeoJSONObjectTypeEnum {
//
// Point(PointDto.class), MultiPoint(MultiPointDto.class), LineString(LineStringDto.class), MultiLineString(
// MultiLineStringDto.class), Polygon(PolygonDto.class), MultiPolygon(
// MultiPolygonDto.class), GeometryCollection(GeometryCollectionDto.class), Feature(
// FeatureDto.class), FeatureCollection(FeatureCollectionDto.class);
//
// private final Class dtoClass;
//
// private GeoJSONObjectTypeEnum(Class dtoClass) {
// this.dtoClass = dtoClass;
// }
//
// public Class getDtoClass() {
// return dtoClass;
// }
// }
//
// Path: ugeojson-model/src/main/java/org/ugeojson/model/geometry/LineStringDto.java
// public class LineStringDto extends GeometryDto {
//
// private static final long serialVersionUID = 1L;
//
// private List<PositionDto> positions;
//
// public LineStringDto(){
// }
//
// public LineStringDto(List<PositionDto> positions){
// this.positions = new ArrayList<>();
// for (PositionDto positionDto : positions) {
// this.positions.add(new PositionDto(positionDto));
// }
// }
//
// public List<PositionDto> getPositions() {
// return positions;
// }
//
// public void setPositions(List<PositionDto> positions) {
// this.positions = positions;
// }
//
// @Override
// public GeoJSONObjectTypeEnum getGeoJSONObjectType() {
// return GeoJSONObjectTypeEnum.LineString;
// }
// }
// Path: ugeojson-builder/src/main/java/org/ugeojson/builder/geometry/LineStringBuilder.java
import org.ugeojson.builder.common.BuilderConstants;
import org.ugeojson.model.GeoJSONObjectTypeEnum;
import org.ugeojson.model.geometry.LineStringDto;
package org.ugeojson.builder.geometry;
/**
* @author moksuzer
*
*/
public class LineStringBuilder extends GeometryBuilder<LineStringDto> {
private static final LineStringBuilder INSTANCE = new LineStringBuilder();
public static LineStringBuilder getInstance() {
return INSTANCE;
}
private LineStringBuilder() {
}
@Override
public String toGeoJSON(LineStringDto lineString) {
if (lineString == null || lineString.getPositions() == null || lineString.getPositions().isEmpty()) {
return BuilderConstants.NULL_VALUE;
}
StringBuilder builder = initializeBuilder(); | buildTypePart(builder, GeoJSONObjectTypeEnum.LineString); |
mokszr/ultimate-geojson | ugeojson-builder/src/main/java/org/ugeojson/builder/exception/InvalidPolygonDtoException.java | // Path: ugeojson-model/src/main/java/org/ugeojson/model/geometry/PolygonDto.java
// public class PolygonDto extends GeometryDto {
//
// private static final long serialVersionUID = 1L;
//
// private List<LineStringDto> linearRings;
//
// @Override
// public GeoJSONObjectTypeEnum getGeoJSONObjectType() {
// return GeoJSONObjectTypeEnum.Polygon;
// }
//
// public List<LineStringDto> getLinearRings() {
// return linearRings;
// }
//
// public void setLinearRings(List<LineStringDto> linearRings) {
// this.linearRings = linearRings;
// }
//
// }
| import org.ugeojson.model.geometry.PolygonDto; | package org.ugeojson.builder.exception;
public class InvalidPolygonDtoException extends RuntimeException {
private static final long serialVersionUID = 1L; | // Path: ugeojson-model/src/main/java/org/ugeojson/model/geometry/PolygonDto.java
// public class PolygonDto extends GeometryDto {
//
// private static final long serialVersionUID = 1L;
//
// private List<LineStringDto> linearRings;
//
// @Override
// public GeoJSONObjectTypeEnum getGeoJSONObjectType() {
// return GeoJSONObjectTypeEnum.Polygon;
// }
//
// public List<LineStringDto> getLinearRings() {
// return linearRings;
// }
//
// public void setLinearRings(List<LineStringDto> linearRings) {
// this.linearRings = linearRings;
// }
//
// }
// Path: ugeojson-builder/src/main/java/org/ugeojson/builder/exception/InvalidPolygonDtoException.java
import org.ugeojson.model.geometry.PolygonDto;
package org.ugeojson.builder.exception;
public class InvalidPolygonDtoException extends RuntimeException {
private static final long serialVersionUID = 1L; | private final PolygonDto polygon; |
mokszr/ultimate-geojson | ugeojson-builder/src/main/java/org/ugeojson/builder/geometry/MultiLineStringBuilder.java | // Path: ugeojson-builder/src/main/java/org/ugeojson/builder/common/BuilderConstants.java
// public interface BuilderConstants {
//
// public static final String OPEN_BRACKET = "[";
// public static final String CLOSE_BRACKET = "]";
// public static final String OPEN_CURLY_BRACE = "{";
// public static final String CLOSE_CURLY_BRACE = "}";
//
// public static final String COMMA_SPACE = ", ";
// public static final String COMMA = ",";
// public static final String SPACE = " ";
// public static final String COMMA_NEWLINE = ",\n";
// public static final String NEWLINE = "\n";
// public static final String DOUBLE_QUOTE = "\"";
// public static final String NULL_VALUE = "null";
// public static final String TAB_SPACE = " ";
// public static final String EMPTY = "";
//
// public static final String TYPE_SPACE = "\"type\": ";
// public static final String COORDINATES_SPACE = "\"coordinates\": ";
// public static final String GEOMETRIES_SPACE = "\"geometries\": ";
// public static final String GEOMETRY_SPACE = "\"geometry\": ";
// public static final String PROPERTIES_SPACE = "\"properties\": ";
// public static final String ID_SPACE = "\"id\": ";
// public static final String FEATURES_SPACE = "\"features\": ";
// public static final String BBOX_SPACE = "\"bbox\": ";
// }
//
// Path: ugeojson-model/src/main/java/org/ugeojson/model/GeoJSONObjectTypeEnum.java
// public enum GeoJSONObjectTypeEnum {
//
// Point(PointDto.class), MultiPoint(MultiPointDto.class), LineString(LineStringDto.class), MultiLineString(
// MultiLineStringDto.class), Polygon(PolygonDto.class), MultiPolygon(
// MultiPolygonDto.class), GeometryCollection(GeometryCollectionDto.class), Feature(
// FeatureDto.class), FeatureCollection(FeatureCollectionDto.class);
//
// private final Class dtoClass;
//
// private GeoJSONObjectTypeEnum(Class dtoClass) {
// this.dtoClass = dtoClass;
// }
//
// public Class getDtoClass() {
// return dtoClass;
// }
// }
//
// Path: ugeojson-model/src/main/java/org/ugeojson/model/geometry/LineStringDto.java
// public class LineStringDto extends GeometryDto {
//
// private static final long serialVersionUID = 1L;
//
// private List<PositionDto> positions;
//
// public LineStringDto(){
// }
//
// public LineStringDto(List<PositionDto> positions){
// this.positions = new ArrayList<>();
// for (PositionDto positionDto : positions) {
// this.positions.add(new PositionDto(positionDto));
// }
// }
//
// public List<PositionDto> getPositions() {
// return positions;
// }
//
// public void setPositions(List<PositionDto> positions) {
// this.positions = positions;
// }
//
// @Override
// public GeoJSONObjectTypeEnum getGeoJSONObjectType() {
// return GeoJSONObjectTypeEnum.LineString;
// }
// }
//
// Path: ugeojson-model/src/main/java/org/ugeojson/model/geometry/MultiLineStringDto.java
// public class MultiLineStringDto extends GeometryDto {
//
// private static final long serialVersionUID = 1L;
//
// private List<LineStringDto> lines;
//
// public List<LineStringDto> getLines() {
// return lines;
// }
//
// public void setLines(List<LineStringDto> lines) {
// this.lines = lines;
// }
//
// @Override
// public GeoJSONObjectTypeEnum getGeoJSONObjectType() {
// return GeoJSONObjectTypeEnum.MultiLineString;
// }
// }
| import java.util.List;
import org.ugeojson.builder.common.BuilderConstants;
import org.ugeojson.model.GeoJSONObjectTypeEnum;
import org.ugeojson.model.geometry.LineStringDto;
import org.ugeojson.model.geometry.MultiLineStringDto; | package org.ugeojson.builder.geometry;
/**
* @author moksuzer
*
*/
public class MultiLineStringBuilder extends GeometryBuilder<MultiLineStringDto> {
private static final MultiLineStringBuilder INSTANCE = new MultiLineStringBuilder();
public static MultiLineStringBuilder getInstance() {
return INSTANCE;
}
private MultiLineStringBuilder() {
}
@Override
public String toGeoJSON(MultiLineStringDto multiLineString) {
if (multiLineString == null || multiLineString.getLines() == null || multiLineString.getLines().isEmpty()) { | // Path: ugeojson-builder/src/main/java/org/ugeojson/builder/common/BuilderConstants.java
// public interface BuilderConstants {
//
// public static final String OPEN_BRACKET = "[";
// public static final String CLOSE_BRACKET = "]";
// public static final String OPEN_CURLY_BRACE = "{";
// public static final String CLOSE_CURLY_BRACE = "}";
//
// public static final String COMMA_SPACE = ", ";
// public static final String COMMA = ",";
// public static final String SPACE = " ";
// public static final String COMMA_NEWLINE = ",\n";
// public static final String NEWLINE = "\n";
// public static final String DOUBLE_QUOTE = "\"";
// public static final String NULL_VALUE = "null";
// public static final String TAB_SPACE = " ";
// public static final String EMPTY = "";
//
// public static final String TYPE_SPACE = "\"type\": ";
// public static final String COORDINATES_SPACE = "\"coordinates\": ";
// public static final String GEOMETRIES_SPACE = "\"geometries\": ";
// public static final String GEOMETRY_SPACE = "\"geometry\": ";
// public static final String PROPERTIES_SPACE = "\"properties\": ";
// public static final String ID_SPACE = "\"id\": ";
// public static final String FEATURES_SPACE = "\"features\": ";
// public static final String BBOX_SPACE = "\"bbox\": ";
// }
//
// Path: ugeojson-model/src/main/java/org/ugeojson/model/GeoJSONObjectTypeEnum.java
// public enum GeoJSONObjectTypeEnum {
//
// Point(PointDto.class), MultiPoint(MultiPointDto.class), LineString(LineStringDto.class), MultiLineString(
// MultiLineStringDto.class), Polygon(PolygonDto.class), MultiPolygon(
// MultiPolygonDto.class), GeometryCollection(GeometryCollectionDto.class), Feature(
// FeatureDto.class), FeatureCollection(FeatureCollectionDto.class);
//
// private final Class dtoClass;
//
// private GeoJSONObjectTypeEnum(Class dtoClass) {
// this.dtoClass = dtoClass;
// }
//
// public Class getDtoClass() {
// return dtoClass;
// }
// }
//
// Path: ugeojson-model/src/main/java/org/ugeojson/model/geometry/LineStringDto.java
// public class LineStringDto extends GeometryDto {
//
// private static final long serialVersionUID = 1L;
//
// private List<PositionDto> positions;
//
// public LineStringDto(){
// }
//
// public LineStringDto(List<PositionDto> positions){
// this.positions = new ArrayList<>();
// for (PositionDto positionDto : positions) {
// this.positions.add(new PositionDto(positionDto));
// }
// }
//
// public List<PositionDto> getPositions() {
// return positions;
// }
//
// public void setPositions(List<PositionDto> positions) {
// this.positions = positions;
// }
//
// @Override
// public GeoJSONObjectTypeEnum getGeoJSONObjectType() {
// return GeoJSONObjectTypeEnum.LineString;
// }
// }
//
// Path: ugeojson-model/src/main/java/org/ugeojson/model/geometry/MultiLineStringDto.java
// public class MultiLineStringDto extends GeometryDto {
//
// private static final long serialVersionUID = 1L;
//
// private List<LineStringDto> lines;
//
// public List<LineStringDto> getLines() {
// return lines;
// }
//
// public void setLines(List<LineStringDto> lines) {
// this.lines = lines;
// }
//
// @Override
// public GeoJSONObjectTypeEnum getGeoJSONObjectType() {
// return GeoJSONObjectTypeEnum.MultiLineString;
// }
// }
// Path: ugeojson-builder/src/main/java/org/ugeojson/builder/geometry/MultiLineStringBuilder.java
import java.util.List;
import org.ugeojson.builder.common.BuilderConstants;
import org.ugeojson.model.GeoJSONObjectTypeEnum;
import org.ugeojson.model.geometry.LineStringDto;
import org.ugeojson.model.geometry.MultiLineStringDto;
package org.ugeojson.builder.geometry;
/**
* @author moksuzer
*
*/
public class MultiLineStringBuilder extends GeometryBuilder<MultiLineStringDto> {
private static final MultiLineStringBuilder INSTANCE = new MultiLineStringBuilder();
public static MultiLineStringBuilder getInstance() {
return INSTANCE;
}
private MultiLineStringBuilder() {
}
@Override
public String toGeoJSON(MultiLineStringDto multiLineString) {
if (multiLineString == null || multiLineString.getLines() == null || multiLineString.getLines().isEmpty()) { | return BuilderConstants.NULL_VALUE; |
mokszr/ultimate-geojson | ugeojson-builder/src/main/java/org/ugeojson/builder/geometry/MultiLineStringBuilder.java | // Path: ugeojson-builder/src/main/java/org/ugeojson/builder/common/BuilderConstants.java
// public interface BuilderConstants {
//
// public static final String OPEN_BRACKET = "[";
// public static final String CLOSE_BRACKET = "]";
// public static final String OPEN_CURLY_BRACE = "{";
// public static final String CLOSE_CURLY_BRACE = "}";
//
// public static final String COMMA_SPACE = ", ";
// public static final String COMMA = ",";
// public static final String SPACE = " ";
// public static final String COMMA_NEWLINE = ",\n";
// public static final String NEWLINE = "\n";
// public static final String DOUBLE_QUOTE = "\"";
// public static final String NULL_VALUE = "null";
// public static final String TAB_SPACE = " ";
// public static final String EMPTY = "";
//
// public static final String TYPE_SPACE = "\"type\": ";
// public static final String COORDINATES_SPACE = "\"coordinates\": ";
// public static final String GEOMETRIES_SPACE = "\"geometries\": ";
// public static final String GEOMETRY_SPACE = "\"geometry\": ";
// public static final String PROPERTIES_SPACE = "\"properties\": ";
// public static final String ID_SPACE = "\"id\": ";
// public static final String FEATURES_SPACE = "\"features\": ";
// public static final String BBOX_SPACE = "\"bbox\": ";
// }
//
// Path: ugeojson-model/src/main/java/org/ugeojson/model/GeoJSONObjectTypeEnum.java
// public enum GeoJSONObjectTypeEnum {
//
// Point(PointDto.class), MultiPoint(MultiPointDto.class), LineString(LineStringDto.class), MultiLineString(
// MultiLineStringDto.class), Polygon(PolygonDto.class), MultiPolygon(
// MultiPolygonDto.class), GeometryCollection(GeometryCollectionDto.class), Feature(
// FeatureDto.class), FeatureCollection(FeatureCollectionDto.class);
//
// private final Class dtoClass;
//
// private GeoJSONObjectTypeEnum(Class dtoClass) {
// this.dtoClass = dtoClass;
// }
//
// public Class getDtoClass() {
// return dtoClass;
// }
// }
//
// Path: ugeojson-model/src/main/java/org/ugeojson/model/geometry/LineStringDto.java
// public class LineStringDto extends GeometryDto {
//
// private static final long serialVersionUID = 1L;
//
// private List<PositionDto> positions;
//
// public LineStringDto(){
// }
//
// public LineStringDto(List<PositionDto> positions){
// this.positions = new ArrayList<>();
// for (PositionDto positionDto : positions) {
// this.positions.add(new PositionDto(positionDto));
// }
// }
//
// public List<PositionDto> getPositions() {
// return positions;
// }
//
// public void setPositions(List<PositionDto> positions) {
// this.positions = positions;
// }
//
// @Override
// public GeoJSONObjectTypeEnum getGeoJSONObjectType() {
// return GeoJSONObjectTypeEnum.LineString;
// }
// }
//
// Path: ugeojson-model/src/main/java/org/ugeojson/model/geometry/MultiLineStringDto.java
// public class MultiLineStringDto extends GeometryDto {
//
// private static final long serialVersionUID = 1L;
//
// private List<LineStringDto> lines;
//
// public List<LineStringDto> getLines() {
// return lines;
// }
//
// public void setLines(List<LineStringDto> lines) {
// this.lines = lines;
// }
//
// @Override
// public GeoJSONObjectTypeEnum getGeoJSONObjectType() {
// return GeoJSONObjectTypeEnum.MultiLineString;
// }
// }
| import java.util.List;
import org.ugeojson.builder.common.BuilderConstants;
import org.ugeojson.model.GeoJSONObjectTypeEnum;
import org.ugeojson.model.geometry.LineStringDto;
import org.ugeojson.model.geometry.MultiLineStringDto; | package org.ugeojson.builder.geometry;
/**
* @author moksuzer
*
*/
public class MultiLineStringBuilder extends GeometryBuilder<MultiLineStringDto> {
private static final MultiLineStringBuilder INSTANCE = new MultiLineStringBuilder();
public static MultiLineStringBuilder getInstance() {
return INSTANCE;
}
private MultiLineStringBuilder() {
}
@Override
public String toGeoJSON(MultiLineStringDto multiLineString) {
if (multiLineString == null || multiLineString.getLines() == null || multiLineString.getLines().isEmpty()) {
return BuilderConstants.NULL_VALUE;
}
StringBuilder builder = initializeBuilder(); | // Path: ugeojson-builder/src/main/java/org/ugeojson/builder/common/BuilderConstants.java
// public interface BuilderConstants {
//
// public static final String OPEN_BRACKET = "[";
// public static final String CLOSE_BRACKET = "]";
// public static final String OPEN_CURLY_BRACE = "{";
// public static final String CLOSE_CURLY_BRACE = "}";
//
// public static final String COMMA_SPACE = ", ";
// public static final String COMMA = ",";
// public static final String SPACE = " ";
// public static final String COMMA_NEWLINE = ",\n";
// public static final String NEWLINE = "\n";
// public static final String DOUBLE_QUOTE = "\"";
// public static final String NULL_VALUE = "null";
// public static final String TAB_SPACE = " ";
// public static final String EMPTY = "";
//
// public static final String TYPE_SPACE = "\"type\": ";
// public static final String COORDINATES_SPACE = "\"coordinates\": ";
// public static final String GEOMETRIES_SPACE = "\"geometries\": ";
// public static final String GEOMETRY_SPACE = "\"geometry\": ";
// public static final String PROPERTIES_SPACE = "\"properties\": ";
// public static final String ID_SPACE = "\"id\": ";
// public static final String FEATURES_SPACE = "\"features\": ";
// public static final String BBOX_SPACE = "\"bbox\": ";
// }
//
// Path: ugeojson-model/src/main/java/org/ugeojson/model/GeoJSONObjectTypeEnum.java
// public enum GeoJSONObjectTypeEnum {
//
// Point(PointDto.class), MultiPoint(MultiPointDto.class), LineString(LineStringDto.class), MultiLineString(
// MultiLineStringDto.class), Polygon(PolygonDto.class), MultiPolygon(
// MultiPolygonDto.class), GeometryCollection(GeometryCollectionDto.class), Feature(
// FeatureDto.class), FeatureCollection(FeatureCollectionDto.class);
//
// private final Class dtoClass;
//
// private GeoJSONObjectTypeEnum(Class dtoClass) {
// this.dtoClass = dtoClass;
// }
//
// public Class getDtoClass() {
// return dtoClass;
// }
// }
//
// Path: ugeojson-model/src/main/java/org/ugeojson/model/geometry/LineStringDto.java
// public class LineStringDto extends GeometryDto {
//
// private static final long serialVersionUID = 1L;
//
// private List<PositionDto> positions;
//
// public LineStringDto(){
// }
//
// public LineStringDto(List<PositionDto> positions){
// this.positions = new ArrayList<>();
// for (PositionDto positionDto : positions) {
// this.positions.add(new PositionDto(positionDto));
// }
// }
//
// public List<PositionDto> getPositions() {
// return positions;
// }
//
// public void setPositions(List<PositionDto> positions) {
// this.positions = positions;
// }
//
// @Override
// public GeoJSONObjectTypeEnum getGeoJSONObjectType() {
// return GeoJSONObjectTypeEnum.LineString;
// }
// }
//
// Path: ugeojson-model/src/main/java/org/ugeojson/model/geometry/MultiLineStringDto.java
// public class MultiLineStringDto extends GeometryDto {
//
// private static final long serialVersionUID = 1L;
//
// private List<LineStringDto> lines;
//
// public List<LineStringDto> getLines() {
// return lines;
// }
//
// public void setLines(List<LineStringDto> lines) {
// this.lines = lines;
// }
//
// @Override
// public GeoJSONObjectTypeEnum getGeoJSONObjectType() {
// return GeoJSONObjectTypeEnum.MultiLineString;
// }
// }
// Path: ugeojson-builder/src/main/java/org/ugeojson/builder/geometry/MultiLineStringBuilder.java
import java.util.List;
import org.ugeojson.builder.common.BuilderConstants;
import org.ugeojson.model.GeoJSONObjectTypeEnum;
import org.ugeojson.model.geometry.LineStringDto;
import org.ugeojson.model.geometry.MultiLineStringDto;
package org.ugeojson.builder.geometry;
/**
* @author moksuzer
*
*/
public class MultiLineStringBuilder extends GeometryBuilder<MultiLineStringDto> {
private static final MultiLineStringBuilder INSTANCE = new MultiLineStringBuilder();
public static MultiLineStringBuilder getInstance() {
return INSTANCE;
}
private MultiLineStringBuilder() {
}
@Override
public String toGeoJSON(MultiLineStringDto multiLineString) {
if (multiLineString == null || multiLineString.getLines() == null || multiLineString.getLines().isEmpty()) {
return BuilderConstants.NULL_VALUE;
}
StringBuilder builder = initializeBuilder(); | buildTypePart(builder, GeoJSONObjectTypeEnum.MultiLineString); |
mokszr/ultimate-geojson | ugeojson-builder/src/main/java/org/ugeojson/builder/geometry/MultiLineStringBuilder.java | // Path: ugeojson-builder/src/main/java/org/ugeojson/builder/common/BuilderConstants.java
// public interface BuilderConstants {
//
// public static final String OPEN_BRACKET = "[";
// public static final String CLOSE_BRACKET = "]";
// public static final String OPEN_CURLY_BRACE = "{";
// public static final String CLOSE_CURLY_BRACE = "}";
//
// public static final String COMMA_SPACE = ", ";
// public static final String COMMA = ",";
// public static final String SPACE = " ";
// public static final String COMMA_NEWLINE = ",\n";
// public static final String NEWLINE = "\n";
// public static final String DOUBLE_QUOTE = "\"";
// public static final String NULL_VALUE = "null";
// public static final String TAB_SPACE = " ";
// public static final String EMPTY = "";
//
// public static final String TYPE_SPACE = "\"type\": ";
// public static final String COORDINATES_SPACE = "\"coordinates\": ";
// public static final String GEOMETRIES_SPACE = "\"geometries\": ";
// public static final String GEOMETRY_SPACE = "\"geometry\": ";
// public static final String PROPERTIES_SPACE = "\"properties\": ";
// public static final String ID_SPACE = "\"id\": ";
// public static final String FEATURES_SPACE = "\"features\": ";
// public static final String BBOX_SPACE = "\"bbox\": ";
// }
//
// Path: ugeojson-model/src/main/java/org/ugeojson/model/GeoJSONObjectTypeEnum.java
// public enum GeoJSONObjectTypeEnum {
//
// Point(PointDto.class), MultiPoint(MultiPointDto.class), LineString(LineStringDto.class), MultiLineString(
// MultiLineStringDto.class), Polygon(PolygonDto.class), MultiPolygon(
// MultiPolygonDto.class), GeometryCollection(GeometryCollectionDto.class), Feature(
// FeatureDto.class), FeatureCollection(FeatureCollectionDto.class);
//
// private final Class dtoClass;
//
// private GeoJSONObjectTypeEnum(Class dtoClass) {
// this.dtoClass = dtoClass;
// }
//
// public Class getDtoClass() {
// return dtoClass;
// }
// }
//
// Path: ugeojson-model/src/main/java/org/ugeojson/model/geometry/LineStringDto.java
// public class LineStringDto extends GeometryDto {
//
// private static final long serialVersionUID = 1L;
//
// private List<PositionDto> positions;
//
// public LineStringDto(){
// }
//
// public LineStringDto(List<PositionDto> positions){
// this.positions = new ArrayList<>();
// for (PositionDto positionDto : positions) {
// this.positions.add(new PositionDto(positionDto));
// }
// }
//
// public List<PositionDto> getPositions() {
// return positions;
// }
//
// public void setPositions(List<PositionDto> positions) {
// this.positions = positions;
// }
//
// @Override
// public GeoJSONObjectTypeEnum getGeoJSONObjectType() {
// return GeoJSONObjectTypeEnum.LineString;
// }
// }
//
// Path: ugeojson-model/src/main/java/org/ugeojson/model/geometry/MultiLineStringDto.java
// public class MultiLineStringDto extends GeometryDto {
//
// private static final long serialVersionUID = 1L;
//
// private List<LineStringDto> lines;
//
// public List<LineStringDto> getLines() {
// return lines;
// }
//
// public void setLines(List<LineStringDto> lines) {
// this.lines = lines;
// }
//
// @Override
// public GeoJSONObjectTypeEnum getGeoJSONObjectType() {
// return GeoJSONObjectTypeEnum.MultiLineString;
// }
// }
| import java.util.List;
import org.ugeojson.builder.common.BuilderConstants;
import org.ugeojson.model.GeoJSONObjectTypeEnum;
import org.ugeojson.model.geometry.LineStringDto;
import org.ugeojson.model.geometry.MultiLineStringDto; | package org.ugeojson.builder.geometry;
/**
* @author moksuzer
*
*/
public class MultiLineStringBuilder extends GeometryBuilder<MultiLineStringDto> {
private static final MultiLineStringBuilder INSTANCE = new MultiLineStringBuilder();
public static MultiLineStringBuilder getInstance() {
return INSTANCE;
}
private MultiLineStringBuilder() {
}
@Override
public String toGeoJSON(MultiLineStringDto multiLineString) {
if (multiLineString == null || multiLineString.getLines() == null || multiLineString.getLines().isEmpty()) {
return BuilderConstants.NULL_VALUE;
}
StringBuilder builder = initializeBuilder();
buildTypePart(builder, GeoJSONObjectTypeEnum.MultiLineString);
builder.append(BuilderConstants.COORDINATES_SPACE);
builder.append(BuilderConstants.OPEN_BRACKET);
builder.append(BuilderConstants.NEWLINE);
| // Path: ugeojson-builder/src/main/java/org/ugeojson/builder/common/BuilderConstants.java
// public interface BuilderConstants {
//
// public static final String OPEN_BRACKET = "[";
// public static final String CLOSE_BRACKET = "]";
// public static final String OPEN_CURLY_BRACE = "{";
// public static final String CLOSE_CURLY_BRACE = "}";
//
// public static final String COMMA_SPACE = ", ";
// public static final String COMMA = ",";
// public static final String SPACE = " ";
// public static final String COMMA_NEWLINE = ",\n";
// public static final String NEWLINE = "\n";
// public static final String DOUBLE_QUOTE = "\"";
// public static final String NULL_VALUE = "null";
// public static final String TAB_SPACE = " ";
// public static final String EMPTY = "";
//
// public static final String TYPE_SPACE = "\"type\": ";
// public static final String COORDINATES_SPACE = "\"coordinates\": ";
// public static final String GEOMETRIES_SPACE = "\"geometries\": ";
// public static final String GEOMETRY_SPACE = "\"geometry\": ";
// public static final String PROPERTIES_SPACE = "\"properties\": ";
// public static final String ID_SPACE = "\"id\": ";
// public static final String FEATURES_SPACE = "\"features\": ";
// public static final String BBOX_SPACE = "\"bbox\": ";
// }
//
// Path: ugeojson-model/src/main/java/org/ugeojson/model/GeoJSONObjectTypeEnum.java
// public enum GeoJSONObjectTypeEnum {
//
// Point(PointDto.class), MultiPoint(MultiPointDto.class), LineString(LineStringDto.class), MultiLineString(
// MultiLineStringDto.class), Polygon(PolygonDto.class), MultiPolygon(
// MultiPolygonDto.class), GeometryCollection(GeometryCollectionDto.class), Feature(
// FeatureDto.class), FeatureCollection(FeatureCollectionDto.class);
//
// private final Class dtoClass;
//
// private GeoJSONObjectTypeEnum(Class dtoClass) {
// this.dtoClass = dtoClass;
// }
//
// public Class getDtoClass() {
// return dtoClass;
// }
// }
//
// Path: ugeojson-model/src/main/java/org/ugeojson/model/geometry/LineStringDto.java
// public class LineStringDto extends GeometryDto {
//
// private static final long serialVersionUID = 1L;
//
// private List<PositionDto> positions;
//
// public LineStringDto(){
// }
//
// public LineStringDto(List<PositionDto> positions){
// this.positions = new ArrayList<>();
// for (PositionDto positionDto : positions) {
// this.positions.add(new PositionDto(positionDto));
// }
// }
//
// public List<PositionDto> getPositions() {
// return positions;
// }
//
// public void setPositions(List<PositionDto> positions) {
// this.positions = positions;
// }
//
// @Override
// public GeoJSONObjectTypeEnum getGeoJSONObjectType() {
// return GeoJSONObjectTypeEnum.LineString;
// }
// }
//
// Path: ugeojson-model/src/main/java/org/ugeojson/model/geometry/MultiLineStringDto.java
// public class MultiLineStringDto extends GeometryDto {
//
// private static final long serialVersionUID = 1L;
//
// private List<LineStringDto> lines;
//
// public List<LineStringDto> getLines() {
// return lines;
// }
//
// public void setLines(List<LineStringDto> lines) {
// this.lines = lines;
// }
//
// @Override
// public GeoJSONObjectTypeEnum getGeoJSONObjectType() {
// return GeoJSONObjectTypeEnum.MultiLineString;
// }
// }
// Path: ugeojson-builder/src/main/java/org/ugeojson/builder/geometry/MultiLineStringBuilder.java
import java.util.List;
import org.ugeojson.builder.common.BuilderConstants;
import org.ugeojson.model.GeoJSONObjectTypeEnum;
import org.ugeojson.model.geometry.LineStringDto;
import org.ugeojson.model.geometry.MultiLineStringDto;
package org.ugeojson.builder.geometry;
/**
* @author moksuzer
*
*/
public class MultiLineStringBuilder extends GeometryBuilder<MultiLineStringDto> {
private static final MultiLineStringBuilder INSTANCE = new MultiLineStringBuilder();
public static MultiLineStringBuilder getInstance() {
return INSTANCE;
}
private MultiLineStringBuilder() {
}
@Override
public String toGeoJSON(MultiLineStringDto multiLineString) {
if (multiLineString == null || multiLineString.getLines() == null || multiLineString.getLines().isEmpty()) {
return BuilderConstants.NULL_VALUE;
}
StringBuilder builder = initializeBuilder();
buildTypePart(builder, GeoJSONObjectTypeEnum.MultiLineString);
builder.append(BuilderConstants.COORDINATES_SPACE);
builder.append(BuilderConstants.OPEN_BRACKET);
builder.append(BuilderConstants.NEWLINE);
| List<LineStringDto> lines = multiLineString.getLines(); |
mokszr/ultimate-geojson | ugeojson-builder/src/test/java/org/ugeojson/builder/geometry/LineStringBuilderShould.java | // Path: ugeojson-builder/src/main/java/org/ugeojson/builder/geometry/LineStringBuilder.java
// public class LineStringBuilder extends GeometryBuilder<LineStringDto> {
//
// private static final LineStringBuilder INSTANCE = new LineStringBuilder();
//
// public static LineStringBuilder getInstance() {
// return INSTANCE;
// }
//
// private LineStringBuilder() {
// }
//
// @Override
// public String toGeoJSON(LineStringDto lineString) {
// if (lineString == null || lineString.getPositions() == null || lineString.getPositions().isEmpty()) {
// return BuilderConstants.NULL_VALUE;
// }
//
// StringBuilder builder = initializeBuilder();
// buildTypePart(builder, GeoJSONObjectTypeEnum.LineString);
//
// builder.append(BuilderConstants.COORDINATES_SPACE);
// builder.append(BuilderConstants.OPEN_BRACKET);
// builder.append(BuilderConstants.NEWLINE);
//
// buildLineStringPositions(builder, lineString);
//
// builder.append(BuilderConstants.CLOSE_BRACKET);
//
// buildBbox(builder, lineString.getBbox());
// endBuilder(builder);
//
// return builder.toString();
// }
//
// }
//
// Path: ugeojson-model/src/main/java/org/ugeojson/model/PositionDto.java
// public class PositionDto implements Serializable {
//
// private static final long serialVersionUID = 1L;
//
// private double[] numbers;
//
// /**
// * This constructor initializes numbers field to hold two double numbers. Do
// * not use this constructor if you need the third elevation parameter.
// */
// public PositionDto() {
// this.numbers = new double[2];
// }
//
// /**
// * Simple coordinate position constructor
// *
// * @param longitude
// * @param latitude
// */
// public PositionDto(double longitude, double latitude) {
// this.numbers = new double[] { longitude, latitude };
// }
//
// /**
// * Use this constructor if you need elevation parameter
// *
// * @param longitude
// * @param latitude
// * @param elevation
// */
// public PositionDto(double longitude, double latitude, double elevation) {
// this.numbers = new double[] { longitude, latitude, elevation };
// }
//
// /**
// * Copy constructor
// *
// * @param position
// */
// public PositionDto(PositionDto position) {
// if (position != null) {
// double[] copyNumbers = position.getNumbers();
// this.numbers = new double[copyNumbers.length];
// for (int i = 0; i < copyNumbers.length; i++) {
// this.numbers[i] = copyNumbers[i];
// }
// }
// }
//
// @Override
// public String toString() {
// if (numbers == null) {
// return "null numbers[]";
// }
// StringBuilder value = new StringBuilder("[");
// for (int i = 0; i < numbers.length; i++) {
// value.append(numbers[i]);
// if (i < numbers.length - 1) {
// value.append(", ");
// }
// }
// value.append("]");
// return value.toString();
// }
//
// public void setLongitude(double longitude) {
// this.numbers[0] = longitude;
// }
//
// public double getLongitude() {
// return numbers[0];
// }
//
// public void setLatitude(double latitude) {
// this.numbers[1] = latitude;
// }
//
// public double getLatitude() {
// return numbers[1];
// }
//
// public void setElevation(double elevation) {
// this.numbers[2] = elevation;
// }
//
// public double getElevation() {
// return numbers[2];
// }
//
// public double[] getNumbers() {
// return numbers;
// }
//
// public void setNumbers(double[] numbers) {
// this.numbers = numbers;
// }
// }
//
// Path: ugeojson-model/src/main/java/org/ugeojson/model/geometry/LineStringDto.java
// public class LineStringDto extends GeometryDto {
//
// private static final long serialVersionUID = 1L;
//
// private List<PositionDto> positions;
//
// public LineStringDto(){
// }
//
// public LineStringDto(List<PositionDto> positions){
// this.positions = new ArrayList<>();
// for (PositionDto positionDto : positions) {
// this.positions.add(new PositionDto(positionDto));
// }
// }
//
// public List<PositionDto> getPositions() {
// return positions;
// }
//
// public void setPositions(List<PositionDto> positions) {
// this.positions = positions;
// }
//
// @Override
// public GeoJSONObjectTypeEnum getGeoJSONObjectType() {
// return GeoJSONObjectTypeEnum.LineString;
// }
// }
| import static org.hamcrest.CoreMatchers.equalTo;
import static org.junit.Assert.assertThat;
import java.util.ArrayList;
import java.util.List;
import org.junit.Test;
import org.ugeojson.builder.geometry.LineStringBuilder;
import org.ugeojson.model.PositionDto;
import org.ugeojson.model.geometry.LineStringDto; | package org.ugeojson.builder.geometry;
public class LineStringBuilderShould {
@Test
public void build_linestring() { | // Path: ugeojson-builder/src/main/java/org/ugeojson/builder/geometry/LineStringBuilder.java
// public class LineStringBuilder extends GeometryBuilder<LineStringDto> {
//
// private static final LineStringBuilder INSTANCE = new LineStringBuilder();
//
// public static LineStringBuilder getInstance() {
// return INSTANCE;
// }
//
// private LineStringBuilder() {
// }
//
// @Override
// public String toGeoJSON(LineStringDto lineString) {
// if (lineString == null || lineString.getPositions() == null || lineString.getPositions().isEmpty()) {
// return BuilderConstants.NULL_VALUE;
// }
//
// StringBuilder builder = initializeBuilder();
// buildTypePart(builder, GeoJSONObjectTypeEnum.LineString);
//
// builder.append(BuilderConstants.COORDINATES_SPACE);
// builder.append(BuilderConstants.OPEN_BRACKET);
// builder.append(BuilderConstants.NEWLINE);
//
// buildLineStringPositions(builder, lineString);
//
// builder.append(BuilderConstants.CLOSE_BRACKET);
//
// buildBbox(builder, lineString.getBbox());
// endBuilder(builder);
//
// return builder.toString();
// }
//
// }
//
// Path: ugeojson-model/src/main/java/org/ugeojson/model/PositionDto.java
// public class PositionDto implements Serializable {
//
// private static final long serialVersionUID = 1L;
//
// private double[] numbers;
//
// /**
// * This constructor initializes numbers field to hold two double numbers. Do
// * not use this constructor if you need the third elevation parameter.
// */
// public PositionDto() {
// this.numbers = new double[2];
// }
//
// /**
// * Simple coordinate position constructor
// *
// * @param longitude
// * @param latitude
// */
// public PositionDto(double longitude, double latitude) {
// this.numbers = new double[] { longitude, latitude };
// }
//
// /**
// * Use this constructor if you need elevation parameter
// *
// * @param longitude
// * @param latitude
// * @param elevation
// */
// public PositionDto(double longitude, double latitude, double elevation) {
// this.numbers = new double[] { longitude, latitude, elevation };
// }
//
// /**
// * Copy constructor
// *
// * @param position
// */
// public PositionDto(PositionDto position) {
// if (position != null) {
// double[] copyNumbers = position.getNumbers();
// this.numbers = new double[copyNumbers.length];
// for (int i = 0; i < copyNumbers.length; i++) {
// this.numbers[i] = copyNumbers[i];
// }
// }
// }
//
// @Override
// public String toString() {
// if (numbers == null) {
// return "null numbers[]";
// }
// StringBuilder value = new StringBuilder("[");
// for (int i = 0; i < numbers.length; i++) {
// value.append(numbers[i]);
// if (i < numbers.length - 1) {
// value.append(", ");
// }
// }
// value.append("]");
// return value.toString();
// }
//
// public void setLongitude(double longitude) {
// this.numbers[0] = longitude;
// }
//
// public double getLongitude() {
// return numbers[0];
// }
//
// public void setLatitude(double latitude) {
// this.numbers[1] = latitude;
// }
//
// public double getLatitude() {
// return numbers[1];
// }
//
// public void setElevation(double elevation) {
// this.numbers[2] = elevation;
// }
//
// public double getElevation() {
// return numbers[2];
// }
//
// public double[] getNumbers() {
// return numbers;
// }
//
// public void setNumbers(double[] numbers) {
// this.numbers = numbers;
// }
// }
//
// Path: ugeojson-model/src/main/java/org/ugeojson/model/geometry/LineStringDto.java
// public class LineStringDto extends GeometryDto {
//
// private static final long serialVersionUID = 1L;
//
// private List<PositionDto> positions;
//
// public LineStringDto(){
// }
//
// public LineStringDto(List<PositionDto> positions){
// this.positions = new ArrayList<>();
// for (PositionDto positionDto : positions) {
// this.positions.add(new PositionDto(positionDto));
// }
// }
//
// public List<PositionDto> getPositions() {
// return positions;
// }
//
// public void setPositions(List<PositionDto> positions) {
// this.positions = positions;
// }
//
// @Override
// public GeoJSONObjectTypeEnum getGeoJSONObjectType() {
// return GeoJSONObjectTypeEnum.LineString;
// }
// }
// Path: ugeojson-builder/src/test/java/org/ugeojson/builder/geometry/LineStringBuilderShould.java
import static org.hamcrest.CoreMatchers.equalTo;
import static org.junit.Assert.assertThat;
import java.util.ArrayList;
import java.util.List;
import org.junit.Test;
import org.ugeojson.builder.geometry.LineStringBuilder;
import org.ugeojson.model.PositionDto;
import org.ugeojson.model.geometry.LineStringDto;
package org.ugeojson.builder.geometry;
public class LineStringBuilderShould {
@Test
public void build_linestring() { | LineStringDto lineString = new LineStringDto(); |
mokszr/ultimate-geojson | ugeojson-builder/src/test/java/org/ugeojson/builder/geometry/LineStringBuilderShould.java | // Path: ugeojson-builder/src/main/java/org/ugeojson/builder/geometry/LineStringBuilder.java
// public class LineStringBuilder extends GeometryBuilder<LineStringDto> {
//
// private static final LineStringBuilder INSTANCE = new LineStringBuilder();
//
// public static LineStringBuilder getInstance() {
// return INSTANCE;
// }
//
// private LineStringBuilder() {
// }
//
// @Override
// public String toGeoJSON(LineStringDto lineString) {
// if (lineString == null || lineString.getPositions() == null || lineString.getPositions().isEmpty()) {
// return BuilderConstants.NULL_VALUE;
// }
//
// StringBuilder builder = initializeBuilder();
// buildTypePart(builder, GeoJSONObjectTypeEnum.LineString);
//
// builder.append(BuilderConstants.COORDINATES_SPACE);
// builder.append(BuilderConstants.OPEN_BRACKET);
// builder.append(BuilderConstants.NEWLINE);
//
// buildLineStringPositions(builder, lineString);
//
// builder.append(BuilderConstants.CLOSE_BRACKET);
//
// buildBbox(builder, lineString.getBbox());
// endBuilder(builder);
//
// return builder.toString();
// }
//
// }
//
// Path: ugeojson-model/src/main/java/org/ugeojson/model/PositionDto.java
// public class PositionDto implements Serializable {
//
// private static final long serialVersionUID = 1L;
//
// private double[] numbers;
//
// /**
// * This constructor initializes numbers field to hold two double numbers. Do
// * not use this constructor if you need the third elevation parameter.
// */
// public PositionDto() {
// this.numbers = new double[2];
// }
//
// /**
// * Simple coordinate position constructor
// *
// * @param longitude
// * @param latitude
// */
// public PositionDto(double longitude, double latitude) {
// this.numbers = new double[] { longitude, latitude };
// }
//
// /**
// * Use this constructor if you need elevation parameter
// *
// * @param longitude
// * @param latitude
// * @param elevation
// */
// public PositionDto(double longitude, double latitude, double elevation) {
// this.numbers = new double[] { longitude, latitude, elevation };
// }
//
// /**
// * Copy constructor
// *
// * @param position
// */
// public PositionDto(PositionDto position) {
// if (position != null) {
// double[] copyNumbers = position.getNumbers();
// this.numbers = new double[copyNumbers.length];
// for (int i = 0; i < copyNumbers.length; i++) {
// this.numbers[i] = copyNumbers[i];
// }
// }
// }
//
// @Override
// public String toString() {
// if (numbers == null) {
// return "null numbers[]";
// }
// StringBuilder value = new StringBuilder("[");
// for (int i = 0; i < numbers.length; i++) {
// value.append(numbers[i]);
// if (i < numbers.length - 1) {
// value.append(", ");
// }
// }
// value.append("]");
// return value.toString();
// }
//
// public void setLongitude(double longitude) {
// this.numbers[0] = longitude;
// }
//
// public double getLongitude() {
// return numbers[0];
// }
//
// public void setLatitude(double latitude) {
// this.numbers[1] = latitude;
// }
//
// public double getLatitude() {
// return numbers[1];
// }
//
// public void setElevation(double elevation) {
// this.numbers[2] = elevation;
// }
//
// public double getElevation() {
// return numbers[2];
// }
//
// public double[] getNumbers() {
// return numbers;
// }
//
// public void setNumbers(double[] numbers) {
// this.numbers = numbers;
// }
// }
//
// Path: ugeojson-model/src/main/java/org/ugeojson/model/geometry/LineStringDto.java
// public class LineStringDto extends GeometryDto {
//
// private static final long serialVersionUID = 1L;
//
// private List<PositionDto> positions;
//
// public LineStringDto(){
// }
//
// public LineStringDto(List<PositionDto> positions){
// this.positions = new ArrayList<>();
// for (PositionDto positionDto : positions) {
// this.positions.add(new PositionDto(positionDto));
// }
// }
//
// public List<PositionDto> getPositions() {
// return positions;
// }
//
// public void setPositions(List<PositionDto> positions) {
// this.positions = positions;
// }
//
// @Override
// public GeoJSONObjectTypeEnum getGeoJSONObjectType() {
// return GeoJSONObjectTypeEnum.LineString;
// }
// }
| import static org.hamcrest.CoreMatchers.equalTo;
import static org.junit.Assert.assertThat;
import java.util.ArrayList;
import java.util.List;
import org.junit.Test;
import org.ugeojson.builder.geometry.LineStringBuilder;
import org.ugeojson.model.PositionDto;
import org.ugeojson.model.geometry.LineStringDto; | package org.ugeojson.builder.geometry;
public class LineStringBuilderShould {
@Test
public void build_linestring() {
LineStringDto lineString = new LineStringDto(); | // Path: ugeojson-builder/src/main/java/org/ugeojson/builder/geometry/LineStringBuilder.java
// public class LineStringBuilder extends GeometryBuilder<LineStringDto> {
//
// private static final LineStringBuilder INSTANCE = new LineStringBuilder();
//
// public static LineStringBuilder getInstance() {
// return INSTANCE;
// }
//
// private LineStringBuilder() {
// }
//
// @Override
// public String toGeoJSON(LineStringDto lineString) {
// if (lineString == null || lineString.getPositions() == null || lineString.getPositions().isEmpty()) {
// return BuilderConstants.NULL_VALUE;
// }
//
// StringBuilder builder = initializeBuilder();
// buildTypePart(builder, GeoJSONObjectTypeEnum.LineString);
//
// builder.append(BuilderConstants.COORDINATES_SPACE);
// builder.append(BuilderConstants.OPEN_BRACKET);
// builder.append(BuilderConstants.NEWLINE);
//
// buildLineStringPositions(builder, lineString);
//
// builder.append(BuilderConstants.CLOSE_BRACKET);
//
// buildBbox(builder, lineString.getBbox());
// endBuilder(builder);
//
// return builder.toString();
// }
//
// }
//
// Path: ugeojson-model/src/main/java/org/ugeojson/model/PositionDto.java
// public class PositionDto implements Serializable {
//
// private static final long serialVersionUID = 1L;
//
// private double[] numbers;
//
// /**
// * This constructor initializes numbers field to hold two double numbers. Do
// * not use this constructor if you need the third elevation parameter.
// */
// public PositionDto() {
// this.numbers = new double[2];
// }
//
// /**
// * Simple coordinate position constructor
// *
// * @param longitude
// * @param latitude
// */
// public PositionDto(double longitude, double latitude) {
// this.numbers = new double[] { longitude, latitude };
// }
//
// /**
// * Use this constructor if you need elevation parameter
// *
// * @param longitude
// * @param latitude
// * @param elevation
// */
// public PositionDto(double longitude, double latitude, double elevation) {
// this.numbers = new double[] { longitude, latitude, elevation };
// }
//
// /**
// * Copy constructor
// *
// * @param position
// */
// public PositionDto(PositionDto position) {
// if (position != null) {
// double[] copyNumbers = position.getNumbers();
// this.numbers = new double[copyNumbers.length];
// for (int i = 0; i < copyNumbers.length; i++) {
// this.numbers[i] = copyNumbers[i];
// }
// }
// }
//
// @Override
// public String toString() {
// if (numbers == null) {
// return "null numbers[]";
// }
// StringBuilder value = new StringBuilder("[");
// for (int i = 0; i < numbers.length; i++) {
// value.append(numbers[i]);
// if (i < numbers.length - 1) {
// value.append(", ");
// }
// }
// value.append("]");
// return value.toString();
// }
//
// public void setLongitude(double longitude) {
// this.numbers[0] = longitude;
// }
//
// public double getLongitude() {
// return numbers[0];
// }
//
// public void setLatitude(double latitude) {
// this.numbers[1] = latitude;
// }
//
// public double getLatitude() {
// return numbers[1];
// }
//
// public void setElevation(double elevation) {
// this.numbers[2] = elevation;
// }
//
// public double getElevation() {
// return numbers[2];
// }
//
// public double[] getNumbers() {
// return numbers;
// }
//
// public void setNumbers(double[] numbers) {
// this.numbers = numbers;
// }
// }
//
// Path: ugeojson-model/src/main/java/org/ugeojson/model/geometry/LineStringDto.java
// public class LineStringDto extends GeometryDto {
//
// private static final long serialVersionUID = 1L;
//
// private List<PositionDto> positions;
//
// public LineStringDto(){
// }
//
// public LineStringDto(List<PositionDto> positions){
// this.positions = new ArrayList<>();
// for (PositionDto positionDto : positions) {
// this.positions.add(new PositionDto(positionDto));
// }
// }
//
// public List<PositionDto> getPositions() {
// return positions;
// }
//
// public void setPositions(List<PositionDto> positions) {
// this.positions = positions;
// }
//
// @Override
// public GeoJSONObjectTypeEnum getGeoJSONObjectType() {
// return GeoJSONObjectTypeEnum.LineString;
// }
// }
// Path: ugeojson-builder/src/test/java/org/ugeojson/builder/geometry/LineStringBuilderShould.java
import static org.hamcrest.CoreMatchers.equalTo;
import static org.junit.Assert.assertThat;
import java.util.ArrayList;
import java.util.List;
import org.junit.Test;
import org.ugeojson.builder.geometry.LineStringBuilder;
import org.ugeojson.model.PositionDto;
import org.ugeojson.model.geometry.LineStringDto;
package org.ugeojson.builder.geometry;
public class LineStringBuilderShould {
@Test
public void build_linestring() {
LineStringDto lineString = new LineStringDto(); | List<PositionDto> positions = new ArrayList<>(); |
mokszr/ultimate-geojson | ugeojson-builder/src/test/java/org/ugeojson/builder/geometry/LineStringBuilderShould.java | // Path: ugeojson-builder/src/main/java/org/ugeojson/builder/geometry/LineStringBuilder.java
// public class LineStringBuilder extends GeometryBuilder<LineStringDto> {
//
// private static final LineStringBuilder INSTANCE = new LineStringBuilder();
//
// public static LineStringBuilder getInstance() {
// return INSTANCE;
// }
//
// private LineStringBuilder() {
// }
//
// @Override
// public String toGeoJSON(LineStringDto lineString) {
// if (lineString == null || lineString.getPositions() == null || lineString.getPositions().isEmpty()) {
// return BuilderConstants.NULL_VALUE;
// }
//
// StringBuilder builder = initializeBuilder();
// buildTypePart(builder, GeoJSONObjectTypeEnum.LineString);
//
// builder.append(BuilderConstants.COORDINATES_SPACE);
// builder.append(BuilderConstants.OPEN_BRACKET);
// builder.append(BuilderConstants.NEWLINE);
//
// buildLineStringPositions(builder, lineString);
//
// builder.append(BuilderConstants.CLOSE_BRACKET);
//
// buildBbox(builder, lineString.getBbox());
// endBuilder(builder);
//
// return builder.toString();
// }
//
// }
//
// Path: ugeojson-model/src/main/java/org/ugeojson/model/PositionDto.java
// public class PositionDto implements Serializable {
//
// private static final long serialVersionUID = 1L;
//
// private double[] numbers;
//
// /**
// * This constructor initializes numbers field to hold two double numbers. Do
// * not use this constructor if you need the third elevation parameter.
// */
// public PositionDto() {
// this.numbers = new double[2];
// }
//
// /**
// * Simple coordinate position constructor
// *
// * @param longitude
// * @param latitude
// */
// public PositionDto(double longitude, double latitude) {
// this.numbers = new double[] { longitude, latitude };
// }
//
// /**
// * Use this constructor if you need elevation parameter
// *
// * @param longitude
// * @param latitude
// * @param elevation
// */
// public PositionDto(double longitude, double latitude, double elevation) {
// this.numbers = new double[] { longitude, latitude, elevation };
// }
//
// /**
// * Copy constructor
// *
// * @param position
// */
// public PositionDto(PositionDto position) {
// if (position != null) {
// double[] copyNumbers = position.getNumbers();
// this.numbers = new double[copyNumbers.length];
// for (int i = 0; i < copyNumbers.length; i++) {
// this.numbers[i] = copyNumbers[i];
// }
// }
// }
//
// @Override
// public String toString() {
// if (numbers == null) {
// return "null numbers[]";
// }
// StringBuilder value = new StringBuilder("[");
// for (int i = 0; i < numbers.length; i++) {
// value.append(numbers[i]);
// if (i < numbers.length - 1) {
// value.append(", ");
// }
// }
// value.append("]");
// return value.toString();
// }
//
// public void setLongitude(double longitude) {
// this.numbers[0] = longitude;
// }
//
// public double getLongitude() {
// return numbers[0];
// }
//
// public void setLatitude(double latitude) {
// this.numbers[1] = latitude;
// }
//
// public double getLatitude() {
// return numbers[1];
// }
//
// public void setElevation(double elevation) {
// this.numbers[2] = elevation;
// }
//
// public double getElevation() {
// return numbers[2];
// }
//
// public double[] getNumbers() {
// return numbers;
// }
//
// public void setNumbers(double[] numbers) {
// this.numbers = numbers;
// }
// }
//
// Path: ugeojson-model/src/main/java/org/ugeojson/model/geometry/LineStringDto.java
// public class LineStringDto extends GeometryDto {
//
// private static final long serialVersionUID = 1L;
//
// private List<PositionDto> positions;
//
// public LineStringDto(){
// }
//
// public LineStringDto(List<PositionDto> positions){
// this.positions = new ArrayList<>();
// for (PositionDto positionDto : positions) {
// this.positions.add(new PositionDto(positionDto));
// }
// }
//
// public List<PositionDto> getPositions() {
// return positions;
// }
//
// public void setPositions(List<PositionDto> positions) {
// this.positions = positions;
// }
//
// @Override
// public GeoJSONObjectTypeEnum getGeoJSONObjectType() {
// return GeoJSONObjectTypeEnum.LineString;
// }
// }
| import static org.hamcrest.CoreMatchers.equalTo;
import static org.junit.Assert.assertThat;
import java.util.ArrayList;
import java.util.List;
import org.junit.Test;
import org.ugeojson.builder.geometry.LineStringBuilder;
import org.ugeojson.model.PositionDto;
import org.ugeojson.model.geometry.LineStringDto; | package org.ugeojson.builder.geometry;
public class LineStringBuilderShould {
@Test
public void build_linestring() {
LineStringDto lineString = new LineStringDto();
List<PositionDto> positions = new ArrayList<>();
positions.add(new PositionDto(32.123,24.587));
positions.add(new PositionDto(36.1478,29.3645));
lineString.setPositions(positions);
| // Path: ugeojson-builder/src/main/java/org/ugeojson/builder/geometry/LineStringBuilder.java
// public class LineStringBuilder extends GeometryBuilder<LineStringDto> {
//
// private static final LineStringBuilder INSTANCE = new LineStringBuilder();
//
// public static LineStringBuilder getInstance() {
// return INSTANCE;
// }
//
// private LineStringBuilder() {
// }
//
// @Override
// public String toGeoJSON(LineStringDto lineString) {
// if (lineString == null || lineString.getPositions() == null || lineString.getPositions().isEmpty()) {
// return BuilderConstants.NULL_VALUE;
// }
//
// StringBuilder builder = initializeBuilder();
// buildTypePart(builder, GeoJSONObjectTypeEnum.LineString);
//
// builder.append(BuilderConstants.COORDINATES_SPACE);
// builder.append(BuilderConstants.OPEN_BRACKET);
// builder.append(BuilderConstants.NEWLINE);
//
// buildLineStringPositions(builder, lineString);
//
// builder.append(BuilderConstants.CLOSE_BRACKET);
//
// buildBbox(builder, lineString.getBbox());
// endBuilder(builder);
//
// return builder.toString();
// }
//
// }
//
// Path: ugeojson-model/src/main/java/org/ugeojson/model/PositionDto.java
// public class PositionDto implements Serializable {
//
// private static final long serialVersionUID = 1L;
//
// private double[] numbers;
//
// /**
// * This constructor initializes numbers field to hold two double numbers. Do
// * not use this constructor if you need the third elevation parameter.
// */
// public PositionDto() {
// this.numbers = new double[2];
// }
//
// /**
// * Simple coordinate position constructor
// *
// * @param longitude
// * @param latitude
// */
// public PositionDto(double longitude, double latitude) {
// this.numbers = new double[] { longitude, latitude };
// }
//
// /**
// * Use this constructor if you need elevation parameter
// *
// * @param longitude
// * @param latitude
// * @param elevation
// */
// public PositionDto(double longitude, double latitude, double elevation) {
// this.numbers = new double[] { longitude, latitude, elevation };
// }
//
// /**
// * Copy constructor
// *
// * @param position
// */
// public PositionDto(PositionDto position) {
// if (position != null) {
// double[] copyNumbers = position.getNumbers();
// this.numbers = new double[copyNumbers.length];
// for (int i = 0; i < copyNumbers.length; i++) {
// this.numbers[i] = copyNumbers[i];
// }
// }
// }
//
// @Override
// public String toString() {
// if (numbers == null) {
// return "null numbers[]";
// }
// StringBuilder value = new StringBuilder("[");
// for (int i = 0; i < numbers.length; i++) {
// value.append(numbers[i]);
// if (i < numbers.length - 1) {
// value.append(", ");
// }
// }
// value.append("]");
// return value.toString();
// }
//
// public void setLongitude(double longitude) {
// this.numbers[0] = longitude;
// }
//
// public double getLongitude() {
// return numbers[0];
// }
//
// public void setLatitude(double latitude) {
// this.numbers[1] = latitude;
// }
//
// public double getLatitude() {
// return numbers[1];
// }
//
// public void setElevation(double elevation) {
// this.numbers[2] = elevation;
// }
//
// public double getElevation() {
// return numbers[2];
// }
//
// public double[] getNumbers() {
// return numbers;
// }
//
// public void setNumbers(double[] numbers) {
// this.numbers = numbers;
// }
// }
//
// Path: ugeojson-model/src/main/java/org/ugeojson/model/geometry/LineStringDto.java
// public class LineStringDto extends GeometryDto {
//
// private static final long serialVersionUID = 1L;
//
// private List<PositionDto> positions;
//
// public LineStringDto(){
// }
//
// public LineStringDto(List<PositionDto> positions){
// this.positions = new ArrayList<>();
// for (PositionDto positionDto : positions) {
// this.positions.add(new PositionDto(positionDto));
// }
// }
//
// public List<PositionDto> getPositions() {
// return positions;
// }
//
// public void setPositions(List<PositionDto> positions) {
// this.positions = positions;
// }
//
// @Override
// public GeoJSONObjectTypeEnum getGeoJSONObjectType() {
// return GeoJSONObjectTypeEnum.LineString;
// }
// }
// Path: ugeojson-builder/src/test/java/org/ugeojson/builder/geometry/LineStringBuilderShould.java
import static org.hamcrest.CoreMatchers.equalTo;
import static org.junit.Assert.assertThat;
import java.util.ArrayList;
import java.util.List;
import org.junit.Test;
import org.ugeojson.builder.geometry.LineStringBuilder;
import org.ugeojson.model.PositionDto;
import org.ugeojson.model.geometry.LineStringDto;
package org.ugeojson.builder.geometry;
public class LineStringBuilderShould {
@Test
public void build_linestring() {
LineStringDto lineString = new LineStringDto();
List<PositionDto> positions = new ArrayList<>();
positions.add(new PositionDto(32.123,24.587));
positions.add(new PositionDto(36.1478,29.3645));
lineString.setPositions(positions);
| String geometryGeoJSON = LineStringBuilder.getInstance().toGeoJSON(lineString); |
mokszr/ultimate-geojson | ugeojson-model/src/main/java/org/ugeojson/model/geometry/MultiLineStringDto.java | // Path: ugeojson-model/src/main/java/org/ugeojson/model/GeoJSONObjectTypeEnum.java
// public enum GeoJSONObjectTypeEnum {
//
// Point(PointDto.class), MultiPoint(MultiPointDto.class), LineString(LineStringDto.class), MultiLineString(
// MultiLineStringDto.class), Polygon(PolygonDto.class), MultiPolygon(
// MultiPolygonDto.class), GeometryCollection(GeometryCollectionDto.class), Feature(
// FeatureDto.class), FeatureCollection(FeatureCollectionDto.class);
//
// private final Class dtoClass;
//
// private GeoJSONObjectTypeEnum(Class dtoClass) {
// this.dtoClass = dtoClass;
// }
//
// public Class getDtoClass() {
// return dtoClass;
// }
// }
| import java.util.List;
import org.ugeojson.model.GeoJSONObjectTypeEnum; | package org.ugeojson.model.geometry;
/**
* @author moksuzer
*
*/
public class MultiLineStringDto extends GeometryDto {
private static final long serialVersionUID = 1L;
private List<LineStringDto> lines;
public List<LineStringDto> getLines() {
return lines;
}
public void setLines(List<LineStringDto> lines) {
this.lines = lines;
}
@Override | // Path: ugeojson-model/src/main/java/org/ugeojson/model/GeoJSONObjectTypeEnum.java
// public enum GeoJSONObjectTypeEnum {
//
// Point(PointDto.class), MultiPoint(MultiPointDto.class), LineString(LineStringDto.class), MultiLineString(
// MultiLineStringDto.class), Polygon(PolygonDto.class), MultiPolygon(
// MultiPolygonDto.class), GeometryCollection(GeometryCollectionDto.class), Feature(
// FeatureDto.class), FeatureCollection(FeatureCollectionDto.class);
//
// private final Class dtoClass;
//
// private GeoJSONObjectTypeEnum(Class dtoClass) {
// this.dtoClass = dtoClass;
// }
//
// public Class getDtoClass() {
// return dtoClass;
// }
// }
// Path: ugeojson-model/src/main/java/org/ugeojson/model/geometry/MultiLineStringDto.java
import java.util.List;
import org.ugeojson.model.GeoJSONObjectTypeEnum;
package org.ugeojson.model.geometry;
/**
* @author moksuzer
*
*/
public class MultiLineStringDto extends GeometryDto {
private static final long serialVersionUID = 1L;
private List<LineStringDto> lines;
public List<LineStringDto> getLines() {
return lines;
}
public void setLines(List<LineStringDto> lines) {
this.lines = lines;
}
@Override | public GeoJSONObjectTypeEnum getGeoJSONObjectType() { |
mokszr/ultimate-geojson | ugeojson-builder/src/test/java/org/ugeojson/builder/geometry/PointBuilderShould.java | // Path: ugeojson-builder/src/main/java/org/ugeojson/builder/geometry/PointBuilder.java
// public class PointBuilder extends GeometryBuilder<PointDto> {
//
// private static final PointBuilder INSTANCE = new PointBuilder();
//
// public static PointBuilder getInstance() {
// return INSTANCE;
// }
//
// private PointBuilder() {
// }
//
// /*
// * (non-Javadoc)
// *
// * @see
// * org.ugeojson.builder.geometry.GeometryBuilder#toGeometryGeoJSON(com
// * .erumi.ugeojson.model.geometry.GeometryDto)
// */
// @Override
// public String toGeoJSON(PointDto point) {
// if (point == null || point.getPosition() == null || point.getPosition().getNumbers().length == 0) {
// return BuilderConstants.NULL_VALUE;
// }
//
// StringBuilder builder = initializeBuilder();
// buildTypePart(builder, GeoJSONObjectTypeEnum.Point);
//
// builder.append(BuilderConstants.COORDINATES_SPACE);
// builder.append(PositionBuilder.getInstance().position(point.getPosition()));
//
// buildBbox(builder, point.getBbox());
// endBuilder(builder);
//
// return builder.toString();
// }
//
// }
//
// Path: ugeojson-model/src/main/java/org/ugeojson/model/geometry/PointDto.java
// public class PointDto extends GeometryDto {
//
// private static final long serialVersionUID = 1L;
//
// private PositionDto position;
//
// /**
// * Creates two-dimensional position
// */
// public PointDto() {
// this.position = new PositionDto();
// }
//
// /**
// * Creates two-dimensional position with given longitude and latitude
// *
// * @param longitude
// * @param latitude
// */
// public PointDto(double longitude, double latitude) {
// this.position = new PositionDto(longitude, latitude);
// }
//
// /**
// * Creates three-dimensional position with given longitude, latitude and
// * elevation
// *
// * @param longitude
// * @param latitude
// * @param elevation
// */
// public PointDto(double longitude, double latitude, double elevation) {
// this.position = new PositionDto(longitude, latitude, elevation);
// }
//
// /**
// * Creates point with position parameters of given point
// *
// * @param point
// */
// public PointDto(PointDto point) {
// this.position = new PositionDto(point.getPosition());
// }
//
// /**
// * @param position
// */
// public PointDto(PositionDto position) {
// this.position = new PositionDto(position);
// }
//
// public double getLongitude() {
// return this.position.getLongitude();
// }
//
// public void setLongitude(double longitude) {
// this.position.setLongitude(longitude);
// }
//
// public double getLatitude() {
// return this.position.getLatitude();
// }
//
// public void setLatitude(double latitude) {
// this.position.setLatitude(latitude);
// }
//
// public void setElevation(double elevation) {
// this.position.setElevation(elevation);
// }
//
// public double getElevation() {
// return this.position.getElevation();
// }
//
// public PositionDto getPosition() {
// return position;
// }
//
// public void setPosition(PositionDto position) {
// this.position = position;
// }
//
// @Override
// public GeoJSONObjectTypeEnum getGeoJSONObjectType() {
// return GeoJSONObjectTypeEnum.Point;
// }
//
// }
| import static org.hamcrest.CoreMatchers.equalTo;
import static org.junit.Assert.assertThat;
import org.junit.Test;
import org.ugeojson.builder.geometry.PointBuilder;
import org.ugeojson.model.geometry.PointDto; | package org.ugeojson.builder.geometry;
public class PointBuilderShould {
@Test public void
build_point_to_geometry_geojson(){ | // Path: ugeojson-builder/src/main/java/org/ugeojson/builder/geometry/PointBuilder.java
// public class PointBuilder extends GeometryBuilder<PointDto> {
//
// private static final PointBuilder INSTANCE = new PointBuilder();
//
// public static PointBuilder getInstance() {
// return INSTANCE;
// }
//
// private PointBuilder() {
// }
//
// /*
// * (non-Javadoc)
// *
// * @see
// * org.ugeojson.builder.geometry.GeometryBuilder#toGeometryGeoJSON(com
// * .erumi.ugeojson.model.geometry.GeometryDto)
// */
// @Override
// public String toGeoJSON(PointDto point) {
// if (point == null || point.getPosition() == null || point.getPosition().getNumbers().length == 0) {
// return BuilderConstants.NULL_VALUE;
// }
//
// StringBuilder builder = initializeBuilder();
// buildTypePart(builder, GeoJSONObjectTypeEnum.Point);
//
// builder.append(BuilderConstants.COORDINATES_SPACE);
// builder.append(PositionBuilder.getInstance().position(point.getPosition()));
//
// buildBbox(builder, point.getBbox());
// endBuilder(builder);
//
// return builder.toString();
// }
//
// }
//
// Path: ugeojson-model/src/main/java/org/ugeojson/model/geometry/PointDto.java
// public class PointDto extends GeometryDto {
//
// private static final long serialVersionUID = 1L;
//
// private PositionDto position;
//
// /**
// * Creates two-dimensional position
// */
// public PointDto() {
// this.position = new PositionDto();
// }
//
// /**
// * Creates two-dimensional position with given longitude and latitude
// *
// * @param longitude
// * @param latitude
// */
// public PointDto(double longitude, double latitude) {
// this.position = new PositionDto(longitude, latitude);
// }
//
// /**
// * Creates three-dimensional position with given longitude, latitude and
// * elevation
// *
// * @param longitude
// * @param latitude
// * @param elevation
// */
// public PointDto(double longitude, double latitude, double elevation) {
// this.position = new PositionDto(longitude, latitude, elevation);
// }
//
// /**
// * Creates point with position parameters of given point
// *
// * @param point
// */
// public PointDto(PointDto point) {
// this.position = new PositionDto(point.getPosition());
// }
//
// /**
// * @param position
// */
// public PointDto(PositionDto position) {
// this.position = new PositionDto(position);
// }
//
// public double getLongitude() {
// return this.position.getLongitude();
// }
//
// public void setLongitude(double longitude) {
// this.position.setLongitude(longitude);
// }
//
// public double getLatitude() {
// return this.position.getLatitude();
// }
//
// public void setLatitude(double latitude) {
// this.position.setLatitude(latitude);
// }
//
// public void setElevation(double elevation) {
// this.position.setElevation(elevation);
// }
//
// public double getElevation() {
// return this.position.getElevation();
// }
//
// public PositionDto getPosition() {
// return position;
// }
//
// public void setPosition(PositionDto position) {
// this.position = position;
// }
//
// @Override
// public GeoJSONObjectTypeEnum getGeoJSONObjectType() {
// return GeoJSONObjectTypeEnum.Point;
// }
//
// }
// Path: ugeojson-builder/src/test/java/org/ugeojson/builder/geometry/PointBuilderShould.java
import static org.hamcrest.CoreMatchers.equalTo;
import static org.junit.Assert.assertThat;
import org.junit.Test;
import org.ugeojson.builder.geometry.PointBuilder;
import org.ugeojson.model.geometry.PointDto;
package org.ugeojson.builder.geometry;
public class PointBuilderShould {
@Test public void
build_point_to_geometry_geojson(){ | PointDto point = new PointDto(101.2471,37.2368); |
mokszr/ultimate-geojson | ugeojson-builder/src/test/java/org/ugeojson/builder/geometry/PointBuilderShould.java | // Path: ugeojson-builder/src/main/java/org/ugeojson/builder/geometry/PointBuilder.java
// public class PointBuilder extends GeometryBuilder<PointDto> {
//
// private static final PointBuilder INSTANCE = new PointBuilder();
//
// public static PointBuilder getInstance() {
// return INSTANCE;
// }
//
// private PointBuilder() {
// }
//
// /*
// * (non-Javadoc)
// *
// * @see
// * org.ugeojson.builder.geometry.GeometryBuilder#toGeometryGeoJSON(com
// * .erumi.ugeojson.model.geometry.GeometryDto)
// */
// @Override
// public String toGeoJSON(PointDto point) {
// if (point == null || point.getPosition() == null || point.getPosition().getNumbers().length == 0) {
// return BuilderConstants.NULL_VALUE;
// }
//
// StringBuilder builder = initializeBuilder();
// buildTypePart(builder, GeoJSONObjectTypeEnum.Point);
//
// builder.append(BuilderConstants.COORDINATES_SPACE);
// builder.append(PositionBuilder.getInstance().position(point.getPosition()));
//
// buildBbox(builder, point.getBbox());
// endBuilder(builder);
//
// return builder.toString();
// }
//
// }
//
// Path: ugeojson-model/src/main/java/org/ugeojson/model/geometry/PointDto.java
// public class PointDto extends GeometryDto {
//
// private static final long serialVersionUID = 1L;
//
// private PositionDto position;
//
// /**
// * Creates two-dimensional position
// */
// public PointDto() {
// this.position = new PositionDto();
// }
//
// /**
// * Creates two-dimensional position with given longitude and latitude
// *
// * @param longitude
// * @param latitude
// */
// public PointDto(double longitude, double latitude) {
// this.position = new PositionDto(longitude, latitude);
// }
//
// /**
// * Creates three-dimensional position with given longitude, latitude and
// * elevation
// *
// * @param longitude
// * @param latitude
// * @param elevation
// */
// public PointDto(double longitude, double latitude, double elevation) {
// this.position = new PositionDto(longitude, latitude, elevation);
// }
//
// /**
// * Creates point with position parameters of given point
// *
// * @param point
// */
// public PointDto(PointDto point) {
// this.position = new PositionDto(point.getPosition());
// }
//
// /**
// * @param position
// */
// public PointDto(PositionDto position) {
// this.position = new PositionDto(position);
// }
//
// public double getLongitude() {
// return this.position.getLongitude();
// }
//
// public void setLongitude(double longitude) {
// this.position.setLongitude(longitude);
// }
//
// public double getLatitude() {
// return this.position.getLatitude();
// }
//
// public void setLatitude(double latitude) {
// this.position.setLatitude(latitude);
// }
//
// public void setElevation(double elevation) {
// this.position.setElevation(elevation);
// }
//
// public double getElevation() {
// return this.position.getElevation();
// }
//
// public PositionDto getPosition() {
// return position;
// }
//
// public void setPosition(PositionDto position) {
// this.position = position;
// }
//
// @Override
// public GeoJSONObjectTypeEnum getGeoJSONObjectType() {
// return GeoJSONObjectTypeEnum.Point;
// }
//
// }
| import static org.hamcrest.CoreMatchers.equalTo;
import static org.junit.Assert.assertThat;
import org.junit.Test;
import org.ugeojson.builder.geometry.PointBuilder;
import org.ugeojson.model.geometry.PointDto; | package org.ugeojson.builder.geometry;
public class PointBuilderShould {
@Test public void
build_point_to_geometry_geojson(){
PointDto point = new PointDto(101.2471,37.2368); | // Path: ugeojson-builder/src/main/java/org/ugeojson/builder/geometry/PointBuilder.java
// public class PointBuilder extends GeometryBuilder<PointDto> {
//
// private static final PointBuilder INSTANCE = new PointBuilder();
//
// public static PointBuilder getInstance() {
// return INSTANCE;
// }
//
// private PointBuilder() {
// }
//
// /*
// * (non-Javadoc)
// *
// * @see
// * org.ugeojson.builder.geometry.GeometryBuilder#toGeometryGeoJSON(com
// * .erumi.ugeojson.model.geometry.GeometryDto)
// */
// @Override
// public String toGeoJSON(PointDto point) {
// if (point == null || point.getPosition() == null || point.getPosition().getNumbers().length == 0) {
// return BuilderConstants.NULL_VALUE;
// }
//
// StringBuilder builder = initializeBuilder();
// buildTypePart(builder, GeoJSONObjectTypeEnum.Point);
//
// builder.append(BuilderConstants.COORDINATES_SPACE);
// builder.append(PositionBuilder.getInstance().position(point.getPosition()));
//
// buildBbox(builder, point.getBbox());
// endBuilder(builder);
//
// return builder.toString();
// }
//
// }
//
// Path: ugeojson-model/src/main/java/org/ugeojson/model/geometry/PointDto.java
// public class PointDto extends GeometryDto {
//
// private static final long serialVersionUID = 1L;
//
// private PositionDto position;
//
// /**
// * Creates two-dimensional position
// */
// public PointDto() {
// this.position = new PositionDto();
// }
//
// /**
// * Creates two-dimensional position with given longitude and latitude
// *
// * @param longitude
// * @param latitude
// */
// public PointDto(double longitude, double latitude) {
// this.position = new PositionDto(longitude, latitude);
// }
//
// /**
// * Creates three-dimensional position with given longitude, latitude and
// * elevation
// *
// * @param longitude
// * @param latitude
// * @param elevation
// */
// public PointDto(double longitude, double latitude, double elevation) {
// this.position = new PositionDto(longitude, latitude, elevation);
// }
//
// /**
// * Creates point with position parameters of given point
// *
// * @param point
// */
// public PointDto(PointDto point) {
// this.position = new PositionDto(point.getPosition());
// }
//
// /**
// * @param position
// */
// public PointDto(PositionDto position) {
// this.position = new PositionDto(position);
// }
//
// public double getLongitude() {
// return this.position.getLongitude();
// }
//
// public void setLongitude(double longitude) {
// this.position.setLongitude(longitude);
// }
//
// public double getLatitude() {
// return this.position.getLatitude();
// }
//
// public void setLatitude(double latitude) {
// this.position.setLatitude(latitude);
// }
//
// public void setElevation(double elevation) {
// this.position.setElevation(elevation);
// }
//
// public double getElevation() {
// return this.position.getElevation();
// }
//
// public PositionDto getPosition() {
// return position;
// }
//
// public void setPosition(PositionDto position) {
// this.position = position;
// }
//
// @Override
// public GeoJSONObjectTypeEnum getGeoJSONObjectType() {
// return GeoJSONObjectTypeEnum.Point;
// }
//
// }
// Path: ugeojson-builder/src/test/java/org/ugeojson/builder/geometry/PointBuilderShould.java
import static org.hamcrest.CoreMatchers.equalTo;
import static org.junit.Assert.assertThat;
import org.junit.Test;
import org.ugeojson.builder.geometry.PointBuilder;
import org.ugeojson.model.geometry.PointDto;
package org.ugeojson.builder.geometry;
public class PointBuilderShould {
@Test public void
build_point_to_geometry_geojson(){
PointDto point = new PointDto(101.2471,37.2368); | String geometryGeoJSON = PointBuilder.getInstance().toGeoJSON(point); |
mokszr/ultimate-geojson | ugeojson-parser/src/main/java/org/ugeojson/parser/deserializer/GeometryCollectionDeserializer.java | // Path: ugeojson-model/src/main/java/org/ugeojson/model/GeoJSONObjectTypeEnum.java
// public enum GeoJSONObjectTypeEnum {
//
// Point(PointDto.class), MultiPoint(MultiPointDto.class), LineString(LineStringDto.class), MultiLineString(
// MultiLineStringDto.class), Polygon(PolygonDto.class), MultiPolygon(
// MultiPolygonDto.class), GeometryCollection(GeometryCollectionDto.class), Feature(
// FeatureDto.class), FeatureCollection(FeatureCollectionDto.class);
//
// private final Class dtoClass;
//
// private GeoJSONObjectTypeEnum(Class dtoClass) {
// this.dtoClass = dtoClass;
// }
//
// public Class getDtoClass() {
// return dtoClass;
// }
// }
//
// Path: ugeojson-model/src/main/java/org/ugeojson/model/geometry/GeometryCollectionDto.java
// public class GeometryCollectionDto extends GeometryDto {
//
// private static final long serialVersionUID = 1L;
//
// private List<GeometryDto> geometries;
//
// public List<GeometryDto> getGeometries() {
// return geometries;
// }
//
// public void setGeometries(List<GeometryDto> geometries) {
// this.geometries = geometries;
// }
//
// @Override
// public GeoJSONObjectTypeEnum getGeoJSONObjectType() {
// return GeoJSONObjectTypeEnum.GeometryCollection;
// }
// }
//
// Path: ugeojson-model/src/main/java/org/ugeojson/model/geometry/GeometryDto.java
// public abstract class GeometryDto extends GeoJSONObjectDto {
//
// private static final long serialVersionUID = 1L;
//
// }
//
// Path: ugeojson-parser/src/main/java/org/ugeojson/parser/util/BoundingBoxParser.java
// public class BoundingBoxParser {
//
// private static final int TWO_DIMENSIONAL_BBOX_LENGTH = 4;
//
// private BoundingBoxParser() {
// }
//
// public static BoundingBoxDto parseBbox(JsonObject asJsonObject, JsonDeserializationContext context) {
// BoundingBoxDto bboxDto = null;
// JsonElement bboxElement = asJsonObject.get("bbox");
// if (bboxElement != null) {
// double[] bbox = context.deserialize(bboxElement, double[].class);
// bboxDto = new BoundingBoxDto();
// if (bbox.length == TWO_DIMENSIONAL_BBOX_LENGTH) {
// bboxDto.setSouthWestCorner(new PositionDto(bbox[0], bbox[1]));
// bboxDto.setNorthEastCorner(new PositionDto(bbox[2], bbox[3]));
// } else {
// bboxDto.setSouthWestCorner(new PositionDto(bbox[0], bbox[1], bbox[2]));
// bboxDto.setNorthEastCorner(new PositionDto(bbox[3], bbox[4], bbox[5]));
// }
//
// }
// return bboxDto;
// }
//
// }
| import java.lang.reflect.Type;
import java.util.ArrayList;
import java.util.List;
import org.ugeojson.model.GeoJSONObjectTypeEnum;
import org.ugeojson.model.geometry.GeometryCollectionDto;
import org.ugeojson.model.geometry.GeometryDto;
import org.ugeojson.parser.util.BoundingBoxParser;
import com.google.gson.JsonArray;
import com.google.gson.JsonDeserializationContext;
import com.google.gson.JsonDeserializer;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject; | package org.ugeojson.parser.deserializer;
/**
* Deserializer for GeometryCollection
*
* @author moksuzer
*
*/
public class GeometryCollectionDeserializer implements JsonDeserializer<GeometryCollectionDto> {
@Override
public GeometryCollectionDto deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) {
GeometryCollectionDto dto = new GeometryCollectionDto(); | // Path: ugeojson-model/src/main/java/org/ugeojson/model/GeoJSONObjectTypeEnum.java
// public enum GeoJSONObjectTypeEnum {
//
// Point(PointDto.class), MultiPoint(MultiPointDto.class), LineString(LineStringDto.class), MultiLineString(
// MultiLineStringDto.class), Polygon(PolygonDto.class), MultiPolygon(
// MultiPolygonDto.class), GeometryCollection(GeometryCollectionDto.class), Feature(
// FeatureDto.class), FeatureCollection(FeatureCollectionDto.class);
//
// private final Class dtoClass;
//
// private GeoJSONObjectTypeEnum(Class dtoClass) {
// this.dtoClass = dtoClass;
// }
//
// public Class getDtoClass() {
// return dtoClass;
// }
// }
//
// Path: ugeojson-model/src/main/java/org/ugeojson/model/geometry/GeometryCollectionDto.java
// public class GeometryCollectionDto extends GeometryDto {
//
// private static final long serialVersionUID = 1L;
//
// private List<GeometryDto> geometries;
//
// public List<GeometryDto> getGeometries() {
// return geometries;
// }
//
// public void setGeometries(List<GeometryDto> geometries) {
// this.geometries = geometries;
// }
//
// @Override
// public GeoJSONObjectTypeEnum getGeoJSONObjectType() {
// return GeoJSONObjectTypeEnum.GeometryCollection;
// }
// }
//
// Path: ugeojson-model/src/main/java/org/ugeojson/model/geometry/GeometryDto.java
// public abstract class GeometryDto extends GeoJSONObjectDto {
//
// private static final long serialVersionUID = 1L;
//
// }
//
// Path: ugeojson-parser/src/main/java/org/ugeojson/parser/util/BoundingBoxParser.java
// public class BoundingBoxParser {
//
// private static final int TWO_DIMENSIONAL_BBOX_LENGTH = 4;
//
// private BoundingBoxParser() {
// }
//
// public static BoundingBoxDto parseBbox(JsonObject asJsonObject, JsonDeserializationContext context) {
// BoundingBoxDto bboxDto = null;
// JsonElement bboxElement = asJsonObject.get("bbox");
// if (bboxElement != null) {
// double[] bbox = context.deserialize(bboxElement, double[].class);
// bboxDto = new BoundingBoxDto();
// if (bbox.length == TWO_DIMENSIONAL_BBOX_LENGTH) {
// bboxDto.setSouthWestCorner(new PositionDto(bbox[0], bbox[1]));
// bboxDto.setNorthEastCorner(new PositionDto(bbox[2], bbox[3]));
// } else {
// bboxDto.setSouthWestCorner(new PositionDto(bbox[0], bbox[1], bbox[2]));
// bboxDto.setNorthEastCorner(new PositionDto(bbox[3], bbox[4], bbox[5]));
// }
//
// }
// return bboxDto;
// }
//
// }
// Path: ugeojson-parser/src/main/java/org/ugeojson/parser/deserializer/GeometryCollectionDeserializer.java
import java.lang.reflect.Type;
import java.util.ArrayList;
import java.util.List;
import org.ugeojson.model.GeoJSONObjectTypeEnum;
import org.ugeojson.model.geometry.GeometryCollectionDto;
import org.ugeojson.model.geometry.GeometryDto;
import org.ugeojson.parser.util.BoundingBoxParser;
import com.google.gson.JsonArray;
import com.google.gson.JsonDeserializationContext;
import com.google.gson.JsonDeserializer;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
package org.ugeojson.parser.deserializer;
/**
* Deserializer for GeometryCollection
*
* @author moksuzer
*
*/
public class GeometryCollectionDeserializer implements JsonDeserializer<GeometryCollectionDto> {
@Override
public GeometryCollectionDto deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) {
GeometryCollectionDto dto = new GeometryCollectionDto(); | List<GeometryDto> geometries = new ArrayList<>(); |
mokszr/ultimate-geojson | ugeojson-parser/src/main/java/org/ugeojson/parser/deserializer/GeometryCollectionDeserializer.java | // Path: ugeojson-model/src/main/java/org/ugeojson/model/GeoJSONObjectTypeEnum.java
// public enum GeoJSONObjectTypeEnum {
//
// Point(PointDto.class), MultiPoint(MultiPointDto.class), LineString(LineStringDto.class), MultiLineString(
// MultiLineStringDto.class), Polygon(PolygonDto.class), MultiPolygon(
// MultiPolygonDto.class), GeometryCollection(GeometryCollectionDto.class), Feature(
// FeatureDto.class), FeatureCollection(FeatureCollectionDto.class);
//
// private final Class dtoClass;
//
// private GeoJSONObjectTypeEnum(Class dtoClass) {
// this.dtoClass = dtoClass;
// }
//
// public Class getDtoClass() {
// return dtoClass;
// }
// }
//
// Path: ugeojson-model/src/main/java/org/ugeojson/model/geometry/GeometryCollectionDto.java
// public class GeometryCollectionDto extends GeometryDto {
//
// private static final long serialVersionUID = 1L;
//
// private List<GeometryDto> geometries;
//
// public List<GeometryDto> getGeometries() {
// return geometries;
// }
//
// public void setGeometries(List<GeometryDto> geometries) {
// this.geometries = geometries;
// }
//
// @Override
// public GeoJSONObjectTypeEnum getGeoJSONObjectType() {
// return GeoJSONObjectTypeEnum.GeometryCollection;
// }
// }
//
// Path: ugeojson-model/src/main/java/org/ugeojson/model/geometry/GeometryDto.java
// public abstract class GeometryDto extends GeoJSONObjectDto {
//
// private static final long serialVersionUID = 1L;
//
// }
//
// Path: ugeojson-parser/src/main/java/org/ugeojson/parser/util/BoundingBoxParser.java
// public class BoundingBoxParser {
//
// private static final int TWO_DIMENSIONAL_BBOX_LENGTH = 4;
//
// private BoundingBoxParser() {
// }
//
// public static BoundingBoxDto parseBbox(JsonObject asJsonObject, JsonDeserializationContext context) {
// BoundingBoxDto bboxDto = null;
// JsonElement bboxElement = asJsonObject.get("bbox");
// if (bboxElement != null) {
// double[] bbox = context.deserialize(bboxElement, double[].class);
// bboxDto = new BoundingBoxDto();
// if (bbox.length == TWO_DIMENSIONAL_BBOX_LENGTH) {
// bboxDto.setSouthWestCorner(new PositionDto(bbox[0], bbox[1]));
// bboxDto.setNorthEastCorner(new PositionDto(bbox[2], bbox[3]));
// } else {
// bboxDto.setSouthWestCorner(new PositionDto(bbox[0], bbox[1], bbox[2]));
// bboxDto.setNorthEastCorner(new PositionDto(bbox[3], bbox[4], bbox[5]));
// }
//
// }
// return bboxDto;
// }
//
// }
| import java.lang.reflect.Type;
import java.util.ArrayList;
import java.util.List;
import org.ugeojson.model.GeoJSONObjectTypeEnum;
import org.ugeojson.model.geometry.GeometryCollectionDto;
import org.ugeojson.model.geometry.GeometryDto;
import org.ugeojson.parser.util.BoundingBoxParser;
import com.google.gson.JsonArray;
import com.google.gson.JsonDeserializationContext;
import com.google.gson.JsonDeserializer;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject; | package org.ugeojson.parser.deserializer;
/**
* Deserializer for GeometryCollection
*
* @author moksuzer
*
*/
public class GeometryCollectionDeserializer implements JsonDeserializer<GeometryCollectionDto> {
@Override
public GeometryCollectionDto deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) {
GeometryCollectionDto dto = new GeometryCollectionDto();
List<GeometryDto> geometries = new ArrayList<>();
dto.setGeometries(geometries);
JsonObject asJsonObject = json.getAsJsonObject();
JsonArray jsonArray = asJsonObject.get("geometries").getAsJsonArray();
if (jsonArray == null) {
return dto;
}
for (int i = 0; i < jsonArray.size(); i++) {
JsonObject geometryElement = jsonArray.get(i).getAsJsonObject();
String typeOfGeometry = geometryElement.get("type").getAsString(); | // Path: ugeojson-model/src/main/java/org/ugeojson/model/GeoJSONObjectTypeEnum.java
// public enum GeoJSONObjectTypeEnum {
//
// Point(PointDto.class), MultiPoint(MultiPointDto.class), LineString(LineStringDto.class), MultiLineString(
// MultiLineStringDto.class), Polygon(PolygonDto.class), MultiPolygon(
// MultiPolygonDto.class), GeometryCollection(GeometryCollectionDto.class), Feature(
// FeatureDto.class), FeatureCollection(FeatureCollectionDto.class);
//
// private final Class dtoClass;
//
// private GeoJSONObjectTypeEnum(Class dtoClass) {
// this.dtoClass = dtoClass;
// }
//
// public Class getDtoClass() {
// return dtoClass;
// }
// }
//
// Path: ugeojson-model/src/main/java/org/ugeojson/model/geometry/GeometryCollectionDto.java
// public class GeometryCollectionDto extends GeometryDto {
//
// private static final long serialVersionUID = 1L;
//
// private List<GeometryDto> geometries;
//
// public List<GeometryDto> getGeometries() {
// return geometries;
// }
//
// public void setGeometries(List<GeometryDto> geometries) {
// this.geometries = geometries;
// }
//
// @Override
// public GeoJSONObjectTypeEnum getGeoJSONObjectType() {
// return GeoJSONObjectTypeEnum.GeometryCollection;
// }
// }
//
// Path: ugeojson-model/src/main/java/org/ugeojson/model/geometry/GeometryDto.java
// public abstract class GeometryDto extends GeoJSONObjectDto {
//
// private static final long serialVersionUID = 1L;
//
// }
//
// Path: ugeojson-parser/src/main/java/org/ugeojson/parser/util/BoundingBoxParser.java
// public class BoundingBoxParser {
//
// private static final int TWO_DIMENSIONAL_BBOX_LENGTH = 4;
//
// private BoundingBoxParser() {
// }
//
// public static BoundingBoxDto parseBbox(JsonObject asJsonObject, JsonDeserializationContext context) {
// BoundingBoxDto bboxDto = null;
// JsonElement bboxElement = asJsonObject.get("bbox");
// if (bboxElement != null) {
// double[] bbox = context.deserialize(bboxElement, double[].class);
// bboxDto = new BoundingBoxDto();
// if (bbox.length == TWO_DIMENSIONAL_BBOX_LENGTH) {
// bboxDto.setSouthWestCorner(new PositionDto(bbox[0], bbox[1]));
// bboxDto.setNorthEastCorner(new PositionDto(bbox[2], bbox[3]));
// } else {
// bboxDto.setSouthWestCorner(new PositionDto(bbox[0], bbox[1], bbox[2]));
// bboxDto.setNorthEastCorner(new PositionDto(bbox[3], bbox[4], bbox[5]));
// }
//
// }
// return bboxDto;
// }
//
// }
// Path: ugeojson-parser/src/main/java/org/ugeojson/parser/deserializer/GeometryCollectionDeserializer.java
import java.lang.reflect.Type;
import java.util.ArrayList;
import java.util.List;
import org.ugeojson.model.GeoJSONObjectTypeEnum;
import org.ugeojson.model.geometry.GeometryCollectionDto;
import org.ugeojson.model.geometry.GeometryDto;
import org.ugeojson.parser.util.BoundingBoxParser;
import com.google.gson.JsonArray;
import com.google.gson.JsonDeserializationContext;
import com.google.gson.JsonDeserializer;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
package org.ugeojson.parser.deserializer;
/**
* Deserializer for GeometryCollection
*
* @author moksuzer
*
*/
public class GeometryCollectionDeserializer implements JsonDeserializer<GeometryCollectionDto> {
@Override
public GeometryCollectionDto deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) {
GeometryCollectionDto dto = new GeometryCollectionDto();
List<GeometryDto> geometries = new ArrayList<>();
dto.setGeometries(geometries);
JsonObject asJsonObject = json.getAsJsonObject();
JsonArray jsonArray = asJsonObject.get("geometries").getAsJsonArray();
if (jsonArray == null) {
return dto;
}
for (int i = 0; i < jsonArray.size(); i++) {
JsonObject geometryElement = jsonArray.get(i).getAsJsonObject();
String typeOfGeometry = geometryElement.get("type").getAsString(); | GeoJSONObjectTypeEnum typeEnum = GeoJSONObjectTypeEnum.valueOf(typeOfGeometry); |
mokszr/ultimate-geojson | ugeojson-parser/src/main/java/org/ugeojson/parser/deserializer/GeometryCollectionDeserializer.java | // Path: ugeojson-model/src/main/java/org/ugeojson/model/GeoJSONObjectTypeEnum.java
// public enum GeoJSONObjectTypeEnum {
//
// Point(PointDto.class), MultiPoint(MultiPointDto.class), LineString(LineStringDto.class), MultiLineString(
// MultiLineStringDto.class), Polygon(PolygonDto.class), MultiPolygon(
// MultiPolygonDto.class), GeometryCollection(GeometryCollectionDto.class), Feature(
// FeatureDto.class), FeatureCollection(FeatureCollectionDto.class);
//
// private final Class dtoClass;
//
// private GeoJSONObjectTypeEnum(Class dtoClass) {
// this.dtoClass = dtoClass;
// }
//
// public Class getDtoClass() {
// return dtoClass;
// }
// }
//
// Path: ugeojson-model/src/main/java/org/ugeojson/model/geometry/GeometryCollectionDto.java
// public class GeometryCollectionDto extends GeometryDto {
//
// private static final long serialVersionUID = 1L;
//
// private List<GeometryDto> geometries;
//
// public List<GeometryDto> getGeometries() {
// return geometries;
// }
//
// public void setGeometries(List<GeometryDto> geometries) {
// this.geometries = geometries;
// }
//
// @Override
// public GeoJSONObjectTypeEnum getGeoJSONObjectType() {
// return GeoJSONObjectTypeEnum.GeometryCollection;
// }
// }
//
// Path: ugeojson-model/src/main/java/org/ugeojson/model/geometry/GeometryDto.java
// public abstract class GeometryDto extends GeoJSONObjectDto {
//
// private static final long serialVersionUID = 1L;
//
// }
//
// Path: ugeojson-parser/src/main/java/org/ugeojson/parser/util/BoundingBoxParser.java
// public class BoundingBoxParser {
//
// private static final int TWO_DIMENSIONAL_BBOX_LENGTH = 4;
//
// private BoundingBoxParser() {
// }
//
// public static BoundingBoxDto parseBbox(JsonObject asJsonObject, JsonDeserializationContext context) {
// BoundingBoxDto bboxDto = null;
// JsonElement bboxElement = asJsonObject.get("bbox");
// if (bboxElement != null) {
// double[] bbox = context.deserialize(bboxElement, double[].class);
// bboxDto = new BoundingBoxDto();
// if (bbox.length == TWO_DIMENSIONAL_BBOX_LENGTH) {
// bboxDto.setSouthWestCorner(new PositionDto(bbox[0], bbox[1]));
// bboxDto.setNorthEastCorner(new PositionDto(bbox[2], bbox[3]));
// } else {
// bboxDto.setSouthWestCorner(new PositionDto(bbox[0], bbox[1], bbox[2]));
// bboxDto.setNorthEastCorner(new PositionDto(bbox[3], bbox[4], bbox[5]));
// }
//
// }
// return bboxDto;
// }
//
// }
| import java.lang.reflect.Type;
import java.util.ArrayList;
import java.util.List;
import org.ugeojson.model.GeoJSONObjectTypeEnum;
import org.ugeojson.model.geometry.GeometryCollectionDto;
import org.ugeojson.model.geometry.GeometryDto;
import org.ugeojson.parser.util.BoundingBoxParser;
import com.google.gson.JsonArray;
import com.google.gson.JsonDeserializationContext;
import com.google.gson.JsonDeserializer;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject; | package org.ugeojson.parser.deserializer;
/**
* Deserializer for GeometryCollection
*
* @author moksuzer
*
*/
public class GeometryCollectionDeserializer implements JsonDeserializer<GeometryCollectionDto> {
@Override
public GeometryCollectionDto deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) {
GeometryCollectionDto dto = new GeometryCollectionDto();
List<GeometryDto> geometries = new ArrayList<>();
dto.setGeometries(geometries);
JsonObject asJsonObject = json.getAsJsonObject();
JsonArray jsonArray = asJsonObject.get("geometries").getAsJsonArray();
if (jsonArray == null) {
return dto;
}
for (int i = 0; i < jsonArray.size(); i++) {
JsonObject geometryElement = jsonArray.get(i).getAsJsonObject();
String typeOfGeometry = geometryElement.get("type").getAsString();
GeoJSONObjectTypeEnum typeEnum = GeoJSONObjectTypeEnum.valueOf(typeOfGeometry);
GeometryDto geometryDto = context.deserialize(geometryElement, typeEnum.getDtoClass());
geometries.add(geometryDto);
}
| // Path: ugeojson-model/src/main/java/org/ugeojson/model/GeoJSONObjectTypeEnum.java
// public enum GeoJSONObjectTypeEnum {
//
// Point(PointDto.class), MultiPoint(MultiPointDto.class), LineString(LineStringDto.class), MultiLineString(
// MultiLineStringDto.class), Polygon(PolygonDto.class), MultiPolygon(
// MultiPolygonDto.class), GeometryCollection(GeometryCollectionDto.class), Feature(
// FeatureDto.class), FeatureCollection(FeatureCollectionDto.class);
//
// private final Class dtoClass;
//
// private GeoJSONObjectTypeEnum(Class dtoClass) {
// this.dtoClass = dtoClass;
// }
//
// public Class getDtoClass() {
// return dtoClass;
// }
// }
//
// Path: ugeojson-model/src/main/java/org/ugeojson/model/geometry/GeometryCollectionDto.java
// public class GeometryCollectionDto extends GeometryDto {
//
// private static final long serialVersionUID = 1L;
//
// private List<GeometryDto> geometries;
//
// public List<GeometryDto> getGeometries() {
// return geometries;
// }
//
// public void setGeometries(List<GeometryDto> geometries) {
// this.geometries = geometries;
// }
//
// @Override
// public GeoJSONObjectTypeEnum getGeoJSONObjectType() {
// return GeoJSONObjectTypeEnum.GeometryCollection;
// }
// }
//
// Path: ugeojson-model/src/main/java/org/ugeojson/model/geometry/GeometryDto.java
// public abstract class GeometryDto extends GeoJSONObjectDto {
//
// private static final long serialVersionUID = 1L;
//
// }
//
// Path: ugeojson-parser/src/main/java/org/ugeojson/parser/util/BoundingBoxParser.java
// public class BoundingBoxParser {
//
// private static final int TWO_DIMENSIONAL_BBOX_LENGTH = 4;
//
// private BoundingBoxParser() {
// }
//
// public static BoundingBoxDto parseBbox(JsonObject asJsonObject, JsonDeserializationContext context) {
// BoundingBoxDto bboxDto = null;
// JsonElement bboxElement = asJsonObject.get("bbox");
// if (bboxElement != null) {
// double[] bbox = context.deserialize(bboxElement, double[].class);
// bboxDto = new BoundingBoxDto();
// if (bbox.length == TWO_DIMENSIONAL_BBOX_LENGTH) {
// bboxDto.setSouthWestCorner(new PositionDto(bbox[0], bbox[1]));
// bboxDto.setNorthEastCorner(new PositionDto(bbox[2], bbox[3]));
// } else {
// bboxDto.setSouthWestCorner(new PositionDto(bbox[0], bbox[1], bbox[2]));
// bboxDto.setNorthEastCorner(new PositionDto(bbox[3], bbox[4], bbox[5]));
// }
//
// }
// return bboxDto;
// }
//
// }
// Path: ugeojson-parser/src/main/java/org/ugeojson/parser/deserializer/GeometryCollectionDeserializer.java
import java.lang.reflect.Type;
import java.util.ArrayList;
import java.util.List;
import org.ugeojson.model.GeoJSONObjectTypeEnum;
import org.ugeojson.model.geometry.GeometryCollectionDto;
import org.ugeojson.model.geometry.GeometryDto;
import org.ugeojson.parser.util.BoundingBoxParser;
import com.google.gson.JsonArray;
import com.google.gson.JsonDeserializationContext;
import com.google.gson.JsonDeserializer;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
package org.ugeojson.parser.deserializer;
/**
* Deserializer for GeometryCollection
*
* @author moksuzer
*
*/
public class GeometryCollectionDeserializer implements JsonDeserializer<GeometryCollectionDto> {
@Override
public GeometryCollectionDto deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) {
GeometryCollectionDto dto = new GeometryCollectionDto();
List<GeometryDto> geometries = new ArrayList<>();
dto.setGeometries(geometries);
JsonObject asJsonObject = json.getAsJsonObject();
JsonArray jsonArray = asJsonObject.get("geometries").getAsJsonArray();
if (jsonArray == null) {
return dto;
}
for (int i = 0; i < jsonArray.size(); i++) {
JsonObject geometryElement = jsonArray.get(i).getAsJsonObject();
String typeOfGeometry = geometryElement.get("type").getAsString();
GeoJSONObjectTypeEnum typeEnum = GeoJSONObjectTypeEnum.valueOf(typeOfGeometry);
GeometryDto geometryDto = context.deserialize(geometryElement, typeEnum.getDtoClass());
geometries.add(geometryDto);
}
| dto.setBbox(BoundingBoxParser.parseBbox(asJsonObject, context)); |
mokszr/ultimate-geojson | ugeojson-model/src/main/java/org/ugeojson/model/geometry/GeometryCollectionDto.java | // Path: ugeojson-model/src/main/java/org/ugeojson/model/GeoJSONObjectTypeEnum.java
// public enum GeoJSONObjectTypeEnum {
//
// Point(PointDto.class), MultiPoint(MultiPointDto.class), LineString(LineStringDto.class), MultiLineString(
// MultiLineStringDto.class), Polygon(PolygonDto.class), MultiPolygon(
// MultiPolygonDto.class), GeometryCollection(GeometryCollectionDto.class), Feature(
// FeatureDto.class), FeatureCollection(FeatureCollectionDto.class);
//
// private final Class dtoClass;
//
// private GeoJSONObjectTypeEnum(Class dtoClass) {
// this.dtoClass = dtoClass;
// }
//
// public Class getDtoClass() {
// return dtoClass;
// }
// }
| import java.util.List;
import org.ugeojson.model.GeoJSONObjectTypeEnum; | package org.ugeojson.model.geometry;
/**
* @author moksuzer
*
*/
public class GeometryCollectionDto extends GeometryDto {
private static final long serialVersionUID = 1L;
private List<GeometryDto> geometries;
public List<GeometryDto> getGeometries() {
return geometries;
}
public void setGeometries(List<GeometryDto> geometries) {
this.geometries = geometries;
}
@Override | // Path: ugeojson-model/src/main/java/org/ugeojson/model/GeoJSONObjectTypeEnum.java
// public enum GeoJSONObjectTypeEnum {
//
// Point(PointDto.class), MultiPoint(MultiPointDto.class), LineString(LineStringDto.class), MultiLineString(
// MultiLineStringDto.class), Polygon(PolygonDto.class), MultiPolygon(
// MultiPolygonDto.class), GeometryCollection(GeometryCollectionDto.class), Feature(
// FeatureDto.class), FeatureCollection(FeatureCollectionDto.class);
//
// private final Class dtoClass;
//
// private GeoJSONObjectTypeEnum(Class dtoClass) {
// this.dtoClass = dtoClass;
// }
//
// public Class getDtoClass() {
// return dtoClass;
// }
// }
// Path: ugeojson-model/src/main/java/org/ugeojson/model/geometry/GeometryCollectionDto.java
import java.util.List;
import org.ugeojson.model.GeoJSONObjectTypeEnum;
package org.ugeojson.model.geometry;
/**
* @author moksuzer
*
*/
public class GeometryCollectionDto extends GeometryDto {
private static final long serialVersionUID = 1L;
private List<GeometryDto> geometries;
public List<GeometryDto> getGeometries() {
return geometries;
}
public void setGeometries(List<GeometryDto> geometries) {
this.geometries = geometries;
}
@Override | public GeoJSONObjectTypeEnum getGeoJSONObjectType() { |
mokszr/ultimate-geojson | ugeojson-builder/src/main/java/org/ugeojson/builder/exception/InvalidPositionDtoException.java | // Path: ugeojson-model/src/main/java/org/ugeojson/model/PositionDto.java
// public class PositionDto implements Serializable {
//
// private static final long serialVersionUID = 1L;
//
// private double[] numbers;
//
// /**
// * This constructor initializes numbers field to hold two double numbers. Do
// * not use this constructor if you need the third elevation parameter.
// */
// public PositionDto() {
// this.numbers = new double[2];
// }
//
// /**
// * Simple coordinate position constructor
// *
// * @param longitude
// * @param latitude
// */
// public PositionDto(double longitude, double latitude) {
// this.numbers = new double[] { longitude, latitude };
// }
//
// /**
// * Use this constructor if you need elevation parameter
// *
// * @param longitude
// * @param latitude
// * @param elevation
// */
// public PositionDto(double longitude, double latitude, double elevation) {
// this.numbers = new double[] { longitude, latitude, elevation };
// }
//
// /**
// * Copy constructor
// *
// * @param position
// */
// public PositionDto(PositionDto position) {
// if (position != null) {
// double[] copyNumbers = position.getNumbers();
// this.numbers = new double[copyNumbers.length];
// for (int i = 0; i < copyNumbers.length; i++) {
// this.numbers[i] = copyNumbers[i];
// }
// }
// }
//
// @Override
// public String toString() {
// if (numbers == null) {
// return "null numbers[]";
// }
// StringBuilder value = new StringBuilder("[");
// for (int i = 0; i < numbers.length; i++) {
// value.append(numbers[i]);
// if (i < numbers.length - 1) {
// value.append(", ");
// }
// }
// value.append("]");
// return value.toString();
// }
//
// public void setLongitude(double longitude) {
// this.numbers[0] = longitude;
// }
//
// public double getLongitude() {
// return numbers[0];
// }
//
// public void setLatitude(double latitude) {
// this.numbers[1] = latitude;
// }
//
// public double getLatitude() {
// return numbers[1];
// }
//
// public void setElevation(double elevation) {
// this.numbers[2] = elevation;
// }
//
// public double getElevation() {
// return numbers[2];
// }
//
// public double[] getNumbers() {
// return numbers;
// }
//
// public void setNumbers(double[] numbers) {
// this.numbers = numbers;
// }
// }
| import org.ugeojson.model.PositionDto; | package org.ugeojson.builder.exception;
public class InvalidPositionDtoException extends RuntimeException {
private static final long serialVersionUID = 1L;
| // Path: ugeojson-model/src/main/java/org/ugeojson/model/PositionDto.java
// public class PositionDto implements Serializable {
//
// private static final long serialVersionUID = 1L;
//
// private double[] numbers;
//
// /**
// * This constructor initializes numbers field to hold two double numbers. Do
// * not use this constructor if you need the third elevation parameter.
// */
// public PositionDto() {
// this.numbers = new double[2];
// }
//
// /**
// * Simple coordinate position constructor
// *
// * @param longitude
// * @param latitude
// */
// public PositionDto(double longitude, double latitude) {
// this.numbers = new double[] { longitude, latitude };
// }
//
// /**
// * Use this constructor if you need elevation parameter
// *
// * @param longitude
// * @param latitude
// * @param elevation
// */
// public PositionDto(double longitude, double latitude, double elevation) {
// this.numbers = new double[] { longitude, latitude, elevation };
// }
//
// /**
// * Copy constructor
// *
// * @param position
// */
// public PositionDto(PositionDto position) {
// if (position != null) {
// double[] copyNumbers = position.getNumbers();
// this.numbers = new double[copyNumbers.length];
// for (int i = 0; i < copyNumbers.length; i++) {
// this.numbers[i] = copyNumbers[i];
// }
// }
// }
//
// @Override
// public String toString() {
// if (numbers == null) {
// return "null numbers[]";
// }
// StringBuilder value = new StringBuilder("[");
// for (int i = 0; i < numbers.length; i++) {
// value.append(numbers[i]);
// if (i < numbers.length - 1) {
// value.append(", ");
// }
// }
// value.append("]");
// return value.toString();
// }
//
// public void setLongitude(double longitude) {
// this.numbers[0] = longitude;
// }
//
// public double getLongitude() {
// return numbers[0];
// }
//
// public void setLatitude(double latitude) {
// this.numbers[1] = latitude;
// }
//
// public double getLatitude() {
// return numbers[1];
// }
//
// public void setElevation(double elevation) {
// this.numbers[2] = elevation;
// }
//
// public double getElevation() {
// return numbers[2];
// }
//
// public double[] getNumbers() {
// return numbers;
// }
//
// public void setNumbers(double[] numbers) {
// this.numbers = numbers;
// }
// }
// Path: ugeojson-builder/src/main/java/org/ugeojson/builder/exception/InvalidPositionDtoException.java
import org.ugeojson.model.PositionDto;
package org.ugeojson.builder.exception;
public class InvalidPositionDtoException extends RuntimeException {
private static final long serialVersionUID = 1L;
| public InvalidPositionDtoException(PositionDto position) { |
jglrxavpok/JLSL | src/org/jglrxavpok/jlsl/java/JavaEncoder.java | // Path: src/org/jglrxavpok/jlsl/fragments/MethodCallFragment.java
// public static enum InvokeTypes
// {
// STATIC, VIRTUAL, SPECIAL
// }
| import java.io.*;
import java.util.*;
import org.jglrxavpok.jlsl.*;
import org.jglrxavpok.jlsl.fragments.*;
import org.jglrxavpok.jlsl.fragments.MethodCallFragment.InvokeTypes; | else
previousType = toJava(currentMethod.varName2TypeMap.get(withoutPreviousCast));
if(previousType.equals(toJava(fragment.to)))
{
if(DEBUG) System.out.println("GLSLEncoder > Cancelling cast for " + toCast);
}
else
stack.push("(" + toJava(fragment.to) + ")" + toCast);
}
private void handleModFragment(ModFragment fragment, List<CodeFragment> in, int index, PrintWriter out)
{
String a = stack.pop();
String b = stack.pop();
stack.push("(" + b + " % " + a + ")");
}
private void handleMethodCallFragment(MethodCallFragment fragment, List<CodeFragment> in, int index, PrintWriter out)
{
String s = "";
String n = fragment.methodName;
boolean isConstructor = false;
if(n.equals("<init>"))
{
n = "new " + toJava(fragment.methodOwner);
isConstructor = true;
if(!newInstances.isEmpty()) newInstances.pop();
}
String key = fragment.methodName;
if(toJava(fragment.methodOwner) != null && !toJava(fragment.methodOwner).equals("null") && !toJava(fragment.methodOwner).trim().equals("")) key = toJava(fragment.methodOwner) + "." + key; | // Path: src/org/jglrxavpok/jlsl/fragments/MethodCallFragment.java
// public static enum InvokeTypes
// {
// STATIC, VIRTUAL, SPECIAL
// }
// Path: src/org/jglrxavpok/jlsl/java/JavaEncoder.java
import java.io.*;
import java.util.*;
import org.jglrxavpok.jlsl.*;
import org.jglrxavpok.jlsl.fragments.*;
import org.jglrxavpok.jlsl.fragments.MethodCallFragment.InvokeTypes;
else
previousType = toJava(currentMethod.varName2TypeMap.get(withoutPreviousCast));
if(previousType.equals(toJava(fragment.to)))
{
if(DEBUG) System.out.println("GLSLEncoder > Cancelling cast for " + toCast);
}
else
stack.push("(" + toJava(fragment.to) + ")" + toCast);
}
private void handleModFragment(ModFragment fragment, List<CodeFragment> in, int index, PrintWriter out)
{
String a = stack.pop();
String b = stack.pop();
stack.push("(" + b + " % " + a + ")");
}
private void handleMethodCallFragment(MethodCallFragment fragment, List<CodeFragment> in, int index, PrintWriter out)
{
String s = "";
String n = fragment.methodName;
boolean isConstructor = false;
if(n.equals("<init>"))
{
n = "new " + toJava(fragment.methodOwner);
isConstructor = true;
if(!newInstances.isEmpty()) newInstances.pop();
}
String key = fragment.methodName;
if(toJava(fragment.methodOwner) != null && !toJava(fragment.methodOwner).equals("null") && !toJava(fragment.methodOwner).trim().equals("")) key = toJava(fragment.methodOwner) + "." + key; | if(fragment.invokeType == InvokeTypes.SPECIAL && currentMethod.name.equals("<init>") && fragment.methodOwner.equals(currentClass.superclass)) |
jglrxavpok/JLSL | src/org/jglrxavpok/jlsl/glsl/GLSLEncoder.java | // Path: src/org/jglrxavpok/jlsl/fragments/MethodCallFragment.java
// public static enum InvokeTypes
// {
// STATIC, VIRTUAL, SPECIAL
// }
| import java.io.*;
import java.util.*;
import org.jglrxavpok.jlsl.*;
import org.jglrxavpok.jlsl.fragments.*;
import org.jglrxavpok.jlsl.fragments.MethodCallFragment.InvokeTypes;
import org.jglrxavpok.jlsl.glsl.GLSL.Attribute;
import org.jglrxavpok.jlsl.glsl.GLSL.Extensions;
import org.jglrxavpok.jlsl.glsl.GLSL.In;
import org.jglrxavpok.jlsl.glsl.GLSL.Layout;
import org.jglrxavpok.jlsl.glsl.GLSL.Out;
import org.jglrxavpok.jlsl.glsl.GLSL.Substitute;
import org.jglrxavpok.jlsl.glsl.GLSL.Uniform;
import org.jglrxavpok.jlsl.glsl.GLSL.Varying;
import org.jglrxavpok.jlsl.glsl.fragments.*; | else
stack.push("(" + toGLSL(fragment.to) + ")" + toCast);
}
private void handleModFragment(ModFragment fragment, List<CodeFragment> in, int index, PrintWriter out)
{
String a = stack.pop();
String b = stack.pop();
stack.push("mod(" + b + ", " + a + ")");
}
private void handleMethodCallFragment(MethodCallFragment fragment, List<CodeFragment> in, int index, PrintWriter out)
{
String s = "";
String n = fragment.methodName;
boolean isConstructor = false;
if(n.equals("<init>"))
{
n = toGLSL(fragment.methodOwner);
isConstructor = true;
if(!newInstances.isEmpty()) newInstances.pop();
}
String key = fragment.methodName;
if(toGLSL(fragment.methodOwner) != null && !toGLSL(fragment.methodOwner).equals("null") && !toGLSL(fragment.methodOwner).trim().equals("")) key = toGLSL(fragment.methodOwner) + "." + key;
if(methodReplacements.containsKey(key))
{
String nold = key;
n = methodReplacements.get(key);
if(DEBUG) System.out.println("GLSLEncoder > Replacing " + nold + " by " + n);
} | // Path: src/org/jglrxavpok/jlsl/fragments/MethodCallFragment.java
// public static enum InvokeTypes
// {
// STATIC, VIRTUAL, SPECIAL
// }
// Path: src/org/jglrxavpok/jlsl/glsl/GLSLEncoder.java
import java.io.*;
import java.util.*;
import org.jglrxavpok.jlsl.*;
import org.jglrxavpok.jlsl.fragments.*;
import org.jglrxavpok.jlsl.fragments.MethodCallFragment.InvokeTypes;
import org.jglrxavpok.jlsl.glsl.GLSL.Attribute;
import org.jglrxavpok.jlsl.glsl.GLSL.Extensions;
import org.jglrxavpok.jlsl.glsl.GLSL.In;
import org.jglrxavpok.jlsl.glsl.GLSL.Layout;
import org.jglrxavpok.jlsl.glsl.GLSL.Out;
import org.jglrxavpok.jlsl.glsl.GLSL.Substitute;
import org.jglrxavpok.jlsl.glsl.GLSL.Uniform;
import org.jglrxavpok.jlsl.glsl.GLSL.Varying;
import org.jglrxavpok.jlsl.glsl.fragments.*;
else
stack.push("(" + toGLSL(fragment.to) + ")" + toCast);
}
private void handleModFragment(ModFragment fragment, List<CodeFragment> in, int index, PrintWriter out)
{
String a = stack.pop();
String b = stack.pop();
stack.push("mod(" + b + ", " + a + ")");
}
private void handleMethodCallFragment(MethodCallFragment fragment, List<CodeFragment> in, int index, PrintWriter out)
{
String s = "";
String n = fragment.methodName;
boolean isConstructor = false;
if(n.equals("<init>"))
{
n = toGLSL(fragment.methodOwner);
isConstructor = true;
if(!newInstances.isEmpty()) newInstances.pop();
}
String key = fragment.methodName;
if(toGLSL(fragment.methodOwner) != null && !toGLSL(fragment.methodOwner).equals("null") && !toGLSL(fragment.methodOwner).trim().equals("")) key = toGLSL(fragment.methodOwner) + "." + key;
if(methodReplacements.containsKey(key))
{
String nold = key;
n = methodReplacements.get(key);
if(DEBUG) System.out.println("GLSLEncoder > Replacing " + nold + " by " + n);
} | if(fragment.invokeType == InvokeTypes.SPECIAL && currentMethod.name.equals("<init>") && fragment.methodOwner.equals(currentClass.superclass)) |
jglrxavpok/JLSL | src/org/jglrxavpok/jlsl/BytecodeDecoder.java | // Path: src/org/jglrxavpok/jlsl/fragments/MethodCallFragment.java
// public static enum InvokeTypes
// {
// STATIC, VIRTUAL, SPECIAL
// }
| import static org.objectweb.asm.Opcodes.*;
import java.io.*;
import java.util.*;
import org.jglrxavpok.jlsl.fragments.*;
import org.jglrxavpok.jlsl.fragments.MethodCallFragment.InvokeTypes;
import org.objectweb.asm.*;
import org.objectweb.asm.tree.*;
import org.objectweb.asm.util.*; | NewInstanceFragment newFrag = new NewInstanceFragment();
newFrag.type = operand.replace("/", ".");
out.add(newFrag);
}
}
else if(ainsnNode.getType() == AbstractInsnNode.MULTIANEWARRAY_INSN)
{
MultiANewArrayInsnNode multiArrayNode = (MultiANewArrayInsnNode)ainsnNode;
NewMultiArrayFragment multiFrag = new NewMultiArrayFragment();
multiFrag.type = typesFromDesc(multiArrayNode.desc)[0].replace("[]", "");
multiFrag.dimensions = multiArrayNode.dims;
out.add(multiFrag);
}
else if(ainsnNode.getType() == AbstractInsnNode.LINE)
{
LineNumberNode lineNode = (LineNumberNode)ainsnNode;
LineNumberFragment lineNumberFragment = new LineNumberFragment();
lineNumberFragment.line = lineNode.line;
out.add(lineNumberFragment);
}
else if(ainsnNode.getType() == AbstractInsnNode.METHOD_INSN)
{
MethodInsnNode methodNode = (MethodInsnNode)ainsnNode;
if(methodNode.getOpcode() == INVOKESTATIC)
{
String desc = methodNode.desc;
String margs = desc.substring(desc.indexOf('(') + 1, desc.indexOf(')'));
String[] margsArray = typesFromDesc(margs);
String n = methodNode.name;
MethodCallFragment methodFragment = new MethodCallFragment(); | // Path: src/org/jglrxavpok/jlsl/fragments/MethodCallFragment.java
// public static enum InvokeTypes
// {
// STATIC, VIRTUAL, SPECIAL
// }
// Path: src/org/jglrxavpok/jlsl/BytecodeDecoder.java
import static org.objectweb.asm.Opcodes.*;
import java.io.*;
import java.util.*;
import org.jglrxavpok.jlsl.fragments.*;
import org.jglrxavpok.jlsl.fragments.MethodCallFragment.InvokeTypes;
import org.objectweb.asm.*;
import org.objectweb.asm.tree.*;
import org.objectweb.asm.util.*;
NewInstanceFragment newFrag = new NewInstanceFragment();
newFrag.type = operand.replace("/", ".");
out.add(newFrag);
}
}
else if(ainsnNode.getType() == AbstractInsnNode.MULTIANEWARRAY_INSN)
{
MultiANewArrayInsnNode multiArrayNode = (MultiANewArrayInsnNode)ainsnNode;
NewMultiArrayFragment multiFrag = new NewMultiArrayFragment();
multiFrag.type = typesFromDesc(multiArrayNode.desc)[0].replace("[]", "");
multiFrag.dimensions = multiArrayNode.dims;
out.add(multiFrag);
}
else if(ainsnNode.getType() == AbstractInsnNode.LINE)
{
LineNumberNode lineNode = (LineNumberNode)ainsnNode;
LineNumberFragment lineNumberFragment = new LineNumberFragment();
lineNumberFragment.line = lineNode.line;
out.add(lineNumberFragment);
}
else if(ainsnNode.getType() == AbstractInsnNode.METHOD_INSN)
{
MethodInsnNode methodNode = (MethodInsnNode)ainsnNode;
if(methodNode.getOpcode() == INVOKESTATIC)
{
String desc = methodNode.desc;
String margs = desc.substring(desc.indexOf('(') + 1, desc.indexOf(')'));
String[] margsArray = typesFromDesc(margs);
String n = methodNode.name;
MethodCallFragment methodFragment = new MethodCallFragment(); | methodFragment.invokeType = InvokeTypes.STATIC; |
michelelacorte/FlickLauncher | src/com/android/launcher3/wallpaperpicker/glrenderer/BasicTexture.java | // Path: src/com/android/launcher3/wallpaperpicker/common/Utils.java
// public class Utils {
// private static final String TAG = "Utils";
//
// // Throws AssertionError if the input is false.
// public static void assertTrue(boolean cond) {
// if (!cond) {
// throw new AssertionError();
// }
// }
//
// // Returns the next power of two.
// // Returns the input if it is already power of 2.
// // Throws IllegalArgumentException if the input is <= 0 or
// // the answer overflows.
// public static int nextPowerOf2(int n) {
// if (n <= 0 || n > (1 << 30)) throw new IllegalArgumentException("n is invalid: " + n);
// n -= 1;
// n |= n >> 16;
// n |= n >> 8;
// n |= n >> 4;
// n |= n >> 2;
// n |= n >> 1;
// return n + 1;
// }
//
// // Returns the previous power of two.
// // Returns the input if it is already power of 2.
// // Throws IllegalArgumentException if the input is <= 0
// public static int prevPowerOf2(int n) {
// if (n <= 0) throw new IllegalArgumentException();
// return Integer.highestOneBit(n);
// }
//
// // Returns the input value x clamped to the range [min, max].
// public static int clamp(int x, int min, int max) {
// if (x > max) return max;
// if (x < min) return min;
// return x;
// }
//
// public static int ceilLog2(float value) {
// int i;
// for (i = 0; i < 31; i++) {
// if ((1 << i) >= value) break;
// }
// return i;
// }
//
// public static int floorLog2(float value) {
// int i;
// for (i = 0; i < 31; i++) {
// if ((1 << i) > value) break;
// }
// return i - 1;
// }
//
// public static void closeSilently(Closeable c) {
// if (c == null) return;
// try {
// c.close();
// } catch (IOException t) {
// Log.w(TAG, "close fail ", t);
// }
// }
//
// public static RectF getMaxCropRect(
// int inWidth, int inHeight, int outWidth, int outHeight, boolean leftAligned) {
// RectF cropRect = new RectF();
// // Get a crop rect that will fit this
// if (inWidth / (float) inHeight > outWidth / (float) outHeight) {
// cropRect.top = 0;
// cropRect.bottom = inHeight;
// cropRect.left = (inWidth - (outWidth / (float) outHeight) * inHeight) / 2;
// cropRect.right = inWidth - cropRect.left;
// if (leftAligned) {
// cropRect.right -= cropRect.left;
// cropRect.left = 0;
// }
// } else {
// cropRect.left = 0;
// cropRect.right = inWidth;
// cropRect.top = (inHeight - (outHeight / (float) outWidth) * inWidth) / 2;
// cropRect.bottom = inHeight - cropRect.top;
// }
// return cropRect;
// }
//
// /**
// * Find the min x that 1 / x >= scale
// */
// public static int computeSampleSizeLarger(float scale) {
// int initialSize = (int) Math.floor(1f / scale);
// if (initialSize <= 1) return 1;
// return initialSize <= 8 ? prevPowerOf2(initialSize) : (initialSize / 8 * 8);
// }
// }
| import android.util.Log;
import com.android.launcher3.wallpaperpicker.common.Utils;
import java.util.WeakHashMap; |
protected GLCanvas mCanvasRef = null;
private static WeakHashMap<BasicTexture, Object> sAllTextures
= new WeakHashMap<>();
private static ThreadLocal<Class<BasicTexture>> sInFinalizer = new ThreadLocal<>();
protected BasicTexture(GLCanvas canvas, int id, int state) {
setAssociatedCanvas(canvas);
mId = id;
mState = state;
synchronized (sAllTextures) {
sAllTextures.put(this, null);
}
}
protected BasicTexture() {
this(null, 0, STATE_UNLOADED);
}
protected void setAssociatedCanvas(GLCanvas canvas) {
mCanvasRef = canvas;
}
/**
* Sets the content size of this texture. In OpenGL, the actual texture
* size must be of power of 2, the size of the content may be smaller.
*/
public void setSize(int width, int height) {
mWidth = width;
mHeight = height; | // Path: src/com/android/launcher3/wallpaperpicker/common/Utils.java
// public class Utils {
// private static final String TAG = "Utils";
//
// // Throws AssertionError if the input is false.
// public static void assertTrue(boolean cond) {
// if (!cond) {
// throw new AssertionError();
// }
// }
//
// // Returns the next power of two.
// // Returns the input if it is already power of 2.
// // Throws IllegalArgumentException if the input is <= 0 or
// // the answer overflows.
// public static int nextPowerOf2(int n) {
// if (n <= 0 || n > (1 << 30)) throw new IllegalArgumentException("n is invalid: " + n);
// n -= 1;
// n |= n >> 16;
// n |= n >> 8;
// n |= n >> 4;
// n |= n >> 2;
// n |= n >> 1;
// return n + 1;
// }
//
// // Returns the previous power of two.
// // Returns the input if it is already power of 2.
// // Throws IllegalArgumentException if the input is <= 0
// public static int prevPowerOf2(int n) {
// if (n <= 0) throw new IllegalArgumentException();
// return Integer.highestOneBit(n);
// }
//
// // Returns the input value x clamped to the range [min, max].
// public static int clamp(int x, int min, int max) {
// if (x > max) return max;
// if (x < min) return min;
// return x;
// }
//
// public static int ceilLog2(float value) {
// int i;
// for (i = 0; i < 31; i++) {
// if ((1 << i) >= value) break;
// }
// return i;
// }
//
// public static int floorLog2(float value) {
// int i;
// for (i = 0; i < 31; i++) {
// if ((1 << i) > value) break;
// }
// return i - 1;
// }
//
// public static void closeSilently(Closeable c) {
// if (c == null) return;
// try {
// c.close();
// } catch (IOException t) {
// Log.w(TAG, "close fail ", t);
// }
// }
//
// public static RectF getMaxCropRect(
// int inWidth, int inHeight, int outWidth, int outHeight, boolean leftAligned) {
// RectF cropRect = new RectF();
// // Get a crop rect that will fit this
// if (inWidth / (float) inHeight > outWidth / (float) outHeight) {
// cropRect.top = 0;
// cropRect.bottom = inHeight;
// cropRect.left = (inWidth - (outWidth / (float) outHeight) * inHeight) / 2;
// cropRect.right = inWidth - cropRect.left;
// if (leftAligned) {
// cropRect.right -= cropRect.left;
// cropRect.left = 0;
// }
// } else {
// cropRect.left = 0;
// cropRect.right = inWidth;
// cropRect.top = (inHeight - (outHeight / (float) outWidth) * inWidth) / 2;
// cropRect.bottom = inHeight - cropRect.top;
// }
// return cropRect;
// }
//
// /**
// * Find the min x that 1 / x >= scale
// */
// public static int computeSampleSizeLarger(float scale) {
// int initialSize = (int) Math.floor(1f / scale);
// if (initialSize <= 1) return 1;
// return initialSize <= 8 ? prevPowerOf2(initialSize) : (initialSize / 8 * 8);
// }
// }
// Path: src/com/android/launcher3/wallpaperpicker/glrenderer/BasicTexture.java
import android.util.Log;
import com.android.launcher3.wallpaperpicker.common.Utils;
import java.util.WeakHashMap;
protected GLCanvas mCanvasRef = null;
private static WeakHashMap<BasicTexture, Object> sAllTextures
= new WeakHashMap<>();
private static ThreadLocal<Class<BasicTexture>> sInFinalizer = new ThreadLocal<>();
protected BasicTexture(GLCanvas canvas, int id, int state) {
setAssociatedCanvas(canvas);
mId = id;
mState = state;
synchronized (sAllTextures) {
sAllTextures.put(this, null);
}
}
protected BasicTexture() {
this(null, 0, STATE_UNLOADED);
}
protected void setAssociatedCanvas(GLCanvas canvas) {
mCanvasRef = canvas;
}
/**
* Sets the content size of this texture. In OpenGL, the actual texture
* size must be of power of 2, the size of the content may be smaller.
*/
public void setSize(int width, int height) {
mWidth = width;
mHeight = height; | mTextureWidth = width > 0 ? Utils.nextPowerOf2(width) : 0; |
michelelacorte/FlickLauncher | src/com/android/launcher3/wallpaperpicker/glrenderer/BitmapTexture.java | // Path: src/com/android/launcher3/wallpaperpicker/common/Utils.java
// public class Utils {
// private static final String TAG = "Utils";
//
// // Throws AssertionError if the input is false.
// public static void assertTrue(boolean cond) {
// if (!cond) {
// throw new AssertionError();
// }
// }
//
// // Returns the next power of two.
// // Returns the input if it is already power of 2.
// // Throws IllegalArgumentException if the input is <= 0 or
// // the answer overflows.
// public static int nextPowerOf2(int n) {
// if (n <= 0 || n > (1 << 30)) throw new IllegalArgumentException("n is invalid: " + n);
// n -= 1;
// n |= n >> 16;
// n |= n >> 8;
// n |= n >> 4;
// n |= n >> 2;
// n |= n >> 1;
// return n + 1;
// }
//
// // Returns the previous power of two.
// // Returns the input if it is already power of 2.
// // Throws IllegalArgumentException if the input is <= 0
// public static int prevPowerOf2(int n) {
// if (n <= 0) throw new IllegalArgumentException();
// return Integer.highestOneBit(n);
// }
//
// // Returns the input value x clamped to the range [min, max].
// public static int clamp(int x, int min, int max) {
// if (x > max) return max;
// if (x < min) return min;
// return x;
// }
//
// public static int ceilLog2(float value) {
// int i;
// for (i = 0; i < 31; i++) {
// if ((1 << i) >= value) break;
// }
// return i;
// }
//
// public static int floorLog2(float value) {
// int i;
// for (i = 0; i < 31; i++) {
// if ((1 << i) > value) break;
// }
// return i - 1;
// }
//
// public static void closeSilently(Closeable c) {
// if (c == null) return;
// try {
// c.close();
// } catch (IOException t) {
// Log.w(TAG, "close fail ", t);
// }
// }
//
// public static RectF getMaxCropRect(
// int inWidth, int inHeight, int outWidth, int outHeight, boolean leftAligned) {
// RectF cropRect = new RectF();
// // Get a crop rect that will fit this
// if (inWidth / (float) inHeight > outWidth / (float) outHeight) {
// cropRect.top = 0;
// cropRect.bottom = inHeight;
// cropRect.left = (inWidth - (outWidth / (float) outHeight) * inHeight) / 2;
// cropRect.right = inWidth - cropRect.left;
// if (leftAligned) {
// cropRect.right -= cropRect.left;
// cropRect.left = 0;
// }
// } else {
// cropRect.left = 0;
// cropRect.right = inWidth;
// cropRect.top = (inHeight - (outHeight / (float) outWidth) * inWidth) / 2;
// cropRect.bottom = inHeight - cropRect.top;
// }
// return cropRect;
// }
//
// /**
// * Find the min x that 1 / x >= scale
// */
// public static int computeSampleSizeLarger(float scale) {
// int initialSize = (int) Math.floor(1f / scale);
// if (initialSize <= 1) return 1;
// return initialSize <= 8 ? prevPowerOf2(initialSize) : (initialSize / 8 * 8);
// }
// }
| import android.graphics.Bitmap;
import com.android.launcher3.wallpaperpicker.common.Utils; | /*
* Copyright (C) 2010 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.android.launcher3.wallpaperpicker.glrenderer;
// BitmapTexture is a texture whose content is specified by a fixed Bitmap.
//
// The texture does not own the Bitmap. The user should make sure the Bitmap
// is valid during the texture's lifetime. When the texture is recycled, it
// does not free the Bitmap.
public class BitmapTexture extends UploadedTexture {
protected Bitmap mContentBitmap;
public BitmapTexture(Bitmap bitmap) {
super(); | // Path: src/com/android/launcher3/wallpaperpicker/common/Utils.java
// public class Utils {
// private static final String TAG = "Utils";
//
// // Throws AssertionError if the input is false.
// public static void assertTrue(boolean cond) {
// if (!cond) {
// throw new AssertionError();
// }
// }
//
// // Returns the next power of two.
// // Returns the input if it is already power of 2.
// // Throws IllegalArgumentException if the input is <= 0 or
// // the answer overflows.
// public static int nextPowerOf2(int n) {
// if (n <= 0 || n > (1 << 30)) throw new IllegalArgumentException("n is invalid: " + n);
// n -= 1;
// n |= n >> 16;
// n |= n >> 8;
// n |= n >> 4;
// n |= n >> 2;
// n |= n >> 1;
// return n + 1;
// }
//
// // Returns the previous power of two.
// // Returns the input if it is already power of 2.
// // Throws IllegalArgumentException if the input is <= 0
// public static int prevPowerOf2(int n) {
// if (n <= 0) throw new IllegalArgumentException();
// return Integer.highestOneBit(n);
// }
//
// // Returns the input value x clamped to the range [min, max].
// public static int clamp(int x, int min, int max) {
// if (x > max) return max;
// if (x < min) return min;
// return x;
// }
//
// public static int ceilLog2(float value) {
// int i;
// for (i = 0; i < 31; i++) {
// if ((1 << i) >= value) break;
// }
// return i;
// }
//
// public static int floorLog2(float value) {
// int i;
// for (i = 0; i < 31; i++) {
// if ((1 << i) > value) break;
// }
// return i - 1;
// }
//
// public static void closeSilently(Closeable c) {
// if (c == null) return;
// try {
// c.close();
// } catch (IOException t) {
// Log.w(TAG, "close fail ", t);
// }
// }
//
// public static RectF getMaxCropRect(
// int inWidth, int inHeight, int outWidth, int outHeight, boolean leftAligned) {
// RectF cropRect = new RectF();
// // Get a crop rect that will fit this
// if (inWidth / (float) inHeight > outWidth / (float) outHeight) {
// cropRect.top = 0;
// cropRect.bottom = inHeight;
// cropRect.left = (inWidth - (outWidth / (float) outHeight) * inHeight) / 2;
// cropRect.right = inWidth - cropRect.left;
// if (leftAligned) {
// cropRect.right -= cropRect.left;
// cropRect.left = 0;
// }
// } else {
// cropRect.left = 0;
// cropRect.right = inWidth;
// cropRect.top = (inHeight - (outHeight / (float) outWidth) * inWidth) / 2;
// cropRect.bottom = inHeight - cropRect.top;
// }
// return cropRect;
// }
//
// /**
// * Find the min x that 1 / x >= scale
// */
// public static int computeSampleSizeLarger(float scale) {
// int initialSize = (int) Math.floor(1f / scale);
// if (initialSize <= 1) return 1;
// return initialSize <= 8 ? prevPowerOf2(initialSize) : (initialSize / 8 * 8);
// }
// }
// Path: src/com/android/launcher3/wallpaperpicker/glrenderer/BitmapTexture.java
import android.graphics.Bitmap;
import com.android.launcher3.wallpaperpicker.common.Utils;
/*
* Copyright (C) 2010 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.android.launcher3.wallpaperpicker.glrenderer;
// BitmapTexture is a texture whose content is specified by a fixed Bitmap.
//
// The texture does not own the Bitmap. The user should make sure the Bitmap
// is valid during the texture's lifetime. When the texture is recycled, it
// does not free the Bitmap.
public class BitmapTexture extends UploadedTexture {
protected Bitmap mContentBitmap;
public BitmapTexture(Bitmap bitmap) {
super(); | Utils.assertTrue(bitmap != null && !bitmap.isRecycled()); |
michelelacorte/FlickLauncher | src/com/android/launcher3/wallpaperpicker/glrenderer/UploadedTexture.java | // Path: src/com/android/launcher3/wallpaperpicker/common/Utils.java
// public class Utils {
// private static final String TAG = "Utils";
//
// // Throws AssertionError if the input is false.
// public static void assertTrue(boolean cond) {
// if (!cond) {
// throw new AssertionError();
// }
// }
//
// // Returns the next power of two.
// // Returns the input if it is already power of 2.
// // Throws IllegalArgumentException if the input is <= 0 or
// // the answer overflows.
// public static int nextPowerOf2(int n) {
// if (n <= 0 || n > (1 << 30)) throw new IllegalArgumentException("n is invalid: " + n);
// n -= 1;
// n |= n >> 16;
// n |= n >> 8;
// n |= n >> 4;
// n |= n >> 2;
// n |= n >> 1;
// return n + 1;
// }
//
// // Returns the previous power of two.
// // Returns the input if it is already power of 2.
// // Throws IllegalArgumentException if the input is <= 0
// public static int prevPowerOf2(int n) {
// if (n <= 0) throw new IllegalArgumentException();
// return Integer.highestOneBit(n);
// }
//
// // Returns the input value x clamped to the range [min, max].
// public static int clamp(int x, int min, int max) {
// if (x > max) return max;
// if (x < min) return min;
// return x;
// }
//
// public static int ceilLog2(float value) {
// int i;
// for (i = 0; i < 31; i++) {
// if ((1 << i) >= value) break;
// }
// return i;
// }
//
// public static int floorLog2(float value) {
// int i;
// for (i = 0; i < 31; i++) {
// if ((1 << i) > value) break;
// }
// return i - 1;
// }
//
// public static void closeSilently(Closeable c) {
// if (c == null) return;
// try {
// c.close();
// } catch (IOException t) {
// Log.w(TAG, "close fail ", t);
// }
// }
//
// public static RectF getMaxCropRect(
// int inWidth, int inHeight, int outWidth, int outHeight, boolean leftAligned) {
// RectF cropRect = new RectF();
// // Get a crop rect that will fit this
// if (inWidth / (float) inHeight > outWidth / (float) outHeight) {
// cropRect.top = 0;
// cropRect.bottom = inHeight;
// cropRect.left = (inWidth - (outWidth / (float) outHeight) * inHeight) / 2;
// cropRect.right = inWidth - cropRect.left;
// if (leftAligned) {
// cropRect.right -= cropRect.left;
// cropRect.left = 0;
// }
// } else {
// cropRect.left = 0;
// cropRect.right = inWidth;
// cropRect.top = (inHeight - (outHeight / (float) outWidth) * inWidth) / 2;
// cropRect.bottom = inHeight - cropRect.top;
// }
// return cropRect;
// }
//
// /**
// * Find the min x that 1 / x >= scale
// */
// public static int computeSampleSizeLarger(float scale) {
// int initialSize = (int) Math.floor(1f / scale);
// if (initialSize <= 1) return 1;
// return initialSize <= 8 ? prevPowerOf2(initialSize) : (initialSize / 8 * 8);
// }
// }
| import android.graphics.Bitmap;
import android.graphics.Bitmap.Config;
import android.opengl.GLUtils;
import android.util.Pair;
import com.android.launcher3.wallpaperpicker.common.Utils;
import java.util.HashMap; |
protected UploadedTexture() {
super(null, 0, STATE_UNLOADED);
}
private static Bitmap getBorderLine(boolean vertical, Config config, int length) {
BorderKey key = new BorderKey(config, vertical, length);
Bitmap bitmap = sBorderLines.get(key);
if (bitmap == null) {
bitmap = vertical
? Bitmap.createBitmap(1, length, config)
: Bitmap.createBitmap(length, 1, config);
sBorderLines.put(key, bitmap);
}
return bitmap;
}
private Bitmap getBitmap() {
if (mBitmap == null) {
mBitmap = onGetBitmap();
int w = mBitmap.getWidth();
int h = mBitmap.getHeight();
if (mWidth == UNSPECIFIED) {
setSize(w, h);
}
}
return mBitmap;
}
private void freeBitmap() { | // Path: src/com/android/launcher3/wallpaperpicker/common/Utils.java
// public class Utils {
// private static final String TAG = "Utils";
//
// // Throws AssertionError if the input is false.
// public static void assertTrue(boolean cond) {
// if (!cond) {
// throw new AssertionError();
// }
// }
//
// // Returns the next power of two.
// // Returns the input if it is already power of 2.
// // Throws IllegalArgumentException if the input is <= 0 or
// // the answer overflows.
// public static int nextPowerOf2(int n) {
// if (n <= 0 || n > (1 << 30)) throw new IllegalArgumentException("n is invalid: " + n);
// n -= 1;
// n |= n >> 16;
// n |= n >> 8;
// n |= n >> 4;
// n |= n >> 2;
// n |= n >> 1;
// return n + 1;
// }
//
// // Returns the previous power of two.
// // Returns the input if it is already power of 2.
// // Throws IllegalArgumentException if the input is <= 0
// public static int prevPowerOf2(int n) {
// if (n <= 0) throw new IllegalArgumentException();
// return Integer.highestOneBit(n);
// }
//
// // Returns the input value x clamped to the range [min, max].
// public static int clamp(int x, int min, int max) {
// if (x > max) return max;
// if (x < min) return min;
// return x;
// }
//
// public static int ceilLog2(float value) {
// int i;
// for (i = 0; i < 31; i++) {
// if ((1 << i) >= value) break;
// }
// return i;
// }
//
// public static int floorLog2(float value) {
// int i;
// for (i = 0; i < 31; i++) {
// if ((1 << i) > value) break;
// }
// return i - 1;
// }
//
// public static void closeSilently(Closeable c) {
// if (c == null) return;
// try {
// c.close();
// } catch (IOException t) {
// Log.w(TAG, "close fail ", t);
// }
// }
//
// public static RectF getMaxCropRect(
// int inWidth, int inHeight, int outWidth, int outHeight, boolean leftAligned) {
// RectF cropRect = new RectF();
// // Get a crop rect that will fit this
// if (inWidth / (float) inHeight > outWidth / (float) outHeight) {
// cropRect.top = 0;
// cropRect.bottom = inHeight;
// cropRect.left = (inWidth - (outWidth / (float) outHeight) * inHeight) / 2;
// cropRect.right = inWidth - cropRect.left;
// if (leftAligned) {
// cropRect.right -= cropRect.left;
// cropRect.left = 0;
// }
// } else {
// cropRect.left = 0;
// cropRect.right = inWidth;
// cropRect.top = (inHeight - (outHeight / (float) outWidth) * inWidth) / 2;
// cropRect.bottom = inHeight - cropRect.top;
// }
// return cropRect;
// }
//
// /**
// * Find the min x that 1 / x >= scale
// */
// public static int computeSampleSizeLarger(float scale) {
// int initialSize = (int) Math.floor(1f / scale);
// if (initialSize <= 1) return 1;
// return initialSize <= 8 ? prevPowerOf2(initialSize) : (initialSize / 8 * 8);
// }
// }
// Path: src/com/android/launcher3/wallpaperpicker/glrenderer/UploadedTexture.java
import android.graphics.Bitmap;
import android.graphics.Bitmap.Config;
import android.opengl.GLUtils;
import android.util.Pair;
import com.android.launcher3.wallpaperpicker.common.Utils;
import java.util.HashMap;
protected UploadedTexture() {
super(null, 0, STATE_UNLOADED);
}
private static Bitmap getBorderLine(boolean vertical, Config config, int length) {
BorderKey key = new BorderKey(config, vertical, length);
Bitmap bitmap = sBorderLines.get(key);
if (bitmap == null) {
bitmap = vertical
? Bitmap.createBitmap(1, length, config)
: Bitmap.createBitmap(length, 1, config);
sBorderLines.put(key, bitmap);
}
return bitmap;
}
private Bitmap getBitmap() {
if (mBitmap == null) {
mBitmap = onGetBitmap();
int w = mBitmap.getWidth();
int h = mBitmap.getHeight();
if (mWidth == UNSPECIFIED) {
setSize(w, h);
}
}
return mBitmap;
}
private void freeBitmap() { | Utils.assertTrue(mBitmap != null); |
michelelacorte/FlickLauncher | src/com/android/launcher3/wallpaperpicker/SavedWallpaperImages.java | // Path: src/com/android/launcher3/wallpaperpicker/tileinfo/FileWallpaperInfo.java
// public class FileWallpaperInfo extends DrawableThumbWallpaperInfo {
// private static final String TAG = "FileWallpaperInfo";
//
// private final File mFile;
//
// public FileWallpaperInfo(File target, Drawable thumb) {
// super(thumb);
// mFile = target;
// }
//
// @Override
// public void onClick(final WallpaperPickerActivity a) {
// a.setWallpaperButtonEnabled(false);
// final BitmapRegionTileSource.FilePathBitmapSource bitmapSource =
// new BitmapRegionTileSource.FilePathBitmapSource(mFile, a);
// a.setCropViewTileSource(bitmapSource, false, true, null, new Runnable() {
//
// @Override
// public void run() {
// if (bitmapSource.getLoadingState() == BitmapRegionTileSource.BitmapSource.State.LOADED) {
// a.setWallpaperButtonEnabled(true);
// }
// }
// });
// }
//
// @Override
// public void onSave(final WallpaperPickerActivity a) {
// final InputStreamProvider isp = InputStreamProvider.fromUri(a, Uri.fromFile(mFile));
// AsyncTask<Integer, Void, Point> cropTask = new AsyncTask<Integer, Void, Point>() {
//
// @Override
// protected Point doInBackground(Integer... params) {
// InputStream is = null;
// try {
// Point bounds = isp.getImageBounds();
// if (bounds == null) {
// Log.w(TAG, "Error loading image bounds");
// return null;
// }
// is = isp.newStreamNotNull();
// WallpaperManagerCompat.getInstance(a).setStream(is, null, true, params[0]);
// return bounds;
// } catch (IOException e) {
// Log.w(TAG, "cannot write stream to wallpaper", e);
// } finally {
// Utils.closeSilently(is);
// }
// return null;
// }
//
// @Override
// protected void onPostExecute(Point bounds) {
// if (bounds != null) {
// a.setBoundsAndFinish(a.getWallpaperParallaxOffset() == 0f);
// } else {
// Toast.makeText(a, R.string.wallpaper_set_fail, Toast.LENGTH_SHORT).show();
// }
// }
// };
//
// DialogUtils.executeCropTaskAfterPrompt(a, cropTask, a.getOnDialogCancelListener());
// }
//
// @Override
// public boolean isSelectable() {
// return true;
// }
//
// @Override
// public boolean isNamelessWallpaper() {
// return true;
// }
// }
| import java.util.ArrayList;
import java.util.List;
import com.android.launcher3.wallpaperpicker.tileinfo.FileWallpaperInfo;
import android.content.ContentValues;
import android.content.Context;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.drawable.BitmapDrawable;
import android.graphics.drawable.Drawable;
import android.util.Log;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException; | /*
* Copyright (C) 2013 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.android.launcher3.wallpaperpicker;
public class SavedWallpaperImages {
private static String TAG = "SavedWallpaperImages";
| // Path: src/com/android/launcher3/wallpaperpicker/tileinfo/FileWallpaperInfo.java
// public class FileWallpaperInfo extends DrawableThumbWallpaperInfo {
// private static final String TAG = "FileWallpaperInfo";
//
// private final File mFile;
//
// public FileWallpaperInfo(File target, Drawable thumb) {
// super(thumb);
// mFile = target;
// }
//
// @Override
// public void onClick(final WallpaperPickerActivity a) {
// a.setWallpaperButtonEnabled(false);
// final BitmapRegionTileSource.FilePathBitmapSource bitmapSource =
// new BitmapRegionTileSource.FilePathBitmapSource(mFile, a);
// a.setCropViewTileSource(bitmapSource, false, true, null, new Runnable() {
//
// @Override
// public void run() {
// if (bitmapSource.getLoadingState() == BitmapRegionTileSource.BitmapSource.State.LOADED) {
// a.setWallpaperButtonEnabled(true);
// }
// }
// });
// }
//
// @Override
// public void onSave(final WallpaperPickerActivity a) {
// final InputStreamProvider isp = InputStreamProvider.fromUri(a, Uri.fromFile(mFile));
// AsyncTask<Integer, Void, Point> cropTask = new AsyncTask<Integer, Void, Point>() {
//
// @Override
// protected Point doInBackground(Integer... params) {
// InputStream is = null;
// try {
// Point bounds = isp.getImageBounds();
// if (bounds == null) {
// Log.w(TAG, "Error loading image bounds");
// return null;
// }
// is = isp.newStreamNotNull();
// WallpaperManagerCompat.getInstance(a).setStream(is, null, true, params[0]);
// return bounds;
// } catch (IOException e) {
// Log.w(TAG, "cannot write stream to wallpaper", e);
// } finally {
// Utils.closeSilently(is);
// }
// return null;
// }
//
// @Override
// protected void onPostExecute(Point bounds) {
// if (bounds != null) {
// a.setBoundsAndFinish(a.getWallpaperParallaxOffset() == 0f);
// } else {
// Toast.makeText(a, R.string.wallpaper_set_fail, Toast.LENGTH_SHORT).show();
// }
// }
// };
//
// DialogUtils.executeCropTaskAfterPrompt(a, cropTask, a.getOnDialogCancelListener());
// }
//
// @Override
// public boolean isSelectable() {
// return true;
// }
//
// @Override
// public boolean isNamelessWallpaper() {
// return true;
// }
// }
// Path: src/com/android/launcher3/wallpaperpicker/SavedWallpaperImages.java
import java.util.ArrayList;
import java.util.List;
import com.android.launcher3.wallpaperpicker.tileinfo.FileWallpaperInfo;
import android.content.ContentValues;
import android.content.Context;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.drawable.BitmapDrawable;
import android.graphics.drawable.Drawable;
import android.util.Log;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
/*
* Copyright (C) 2013 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.android.launcher3.wallpaperpicker;
public class SavedWallpaperImages {
private static String TAG = "SavedWallpaperImages";
| public static class SavedWallpaperInfo extends FileWallpaperInfo { |
devhub-tud/Java-Gitolite-Manager | src/main/java/nl/tudelft/ewi/gitolite/parser/rules/InlineUserGroup.java | // Path: src/main/java/nl/tudelft/ewi/gitolite/objects/Identifiable.java
// public interface Identifiable extends Comparable<Identifiable>, Serializable {
//
// String getPattern();
//
// @Override
// default int compareTo(Identifiable o) {
// return getPattern().compareTo(o.getPattern());
// }
//
// }
//
// Path: src/main/java/nl/tudelft/ewi/gitolite/objects/Identifier.java
// @Value
// public class Identifier implements Identifiable {
//
// /**
// * The name for the identifier
// */
// private final String pattern;
//
// private final static WeakHashMap<String, WeakReference<Identifier>> identifiableMap = new WeakHashMap<>();
//
// /**
// * Get an identifier. As {@code Identifiers} should be immutable, they are stored in a
// * {@code WeakHashMap} for caching purposes. This method tries to find {@code Identifiers}
// * in the cache first, and only creates a new instance if not. Therefore, this method is
// * preferred over using a constructor.
// *
// * @param name Name for the identifier.
// * @return Identifier
// */
// public static Identifier valueOf(String name) {
// WeakReference<Identifier> ref = identifiableMap.get(name);
// Identifier identifiable;
// if(ref == null || (identifiable = ref.get()) == null) {
// identifiable = new Identifier(name);
// identifiableMap.put(name, new WeakReference<>(identifiable));
// }
// return identifiable;
// }
//
// }
//
// Path: src/main/java/nl/tudelft/ewi/gitolite/util/RecursiveStreamingGroup.java
// public interface RecursiveStreamingGroup<R extends RecursiveStreamingGroup<? extends StreamingGroup, ? extends T>, T> extends StreamingGroup<T> {
//
// /**
// * @return the own members for this group, excluding the recursive members inherited from the groups.
// */
// Stream<T> getOwnMembersStream();
//
// /**
// * @return the groups in this group.
// */
// Stream<R> getOwnGroupsStream();
//
// /**
// * Add a group to this group.
// * @param group Group to add
// */
// void add(R group);
//
// /**
// * @return the members inherited from the groups.
// */
// default Stream<T> getRecursiveInheritedStream() {
// return getOwnGroupsStream().flatMap(StreamingGroup::getMembersStream);
// }
//
// @Override
// default Stream<T> getMembersStream() {
// return Stream.concat(getRecursiveInheritedStream(), getOwnMembersStream());
// }
//
// }
| import com.google.common.collect.Lists;
import lombok.Builder;
import lombok.EqualsAndHashCode;
import com.google.common.base.Joiner;
import lombok.Singular;
import nl.tudelft.ewi.gitolite.objects.Identifiable;
import nl.tudelft.ewi.gitolite.objects.Identifier;
import nl.tudelft.ewi.gitolite.util.RecursiveStreamingGroup;
import java.io.IOException;
import java.io.Writer;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
import java.util.function.Predicate;
import java.util.stream.Stream; | package nl.tudelft.ewi.gitolite.parser.rules;
/**
* @author Jan-Willem Gmelig Meyling
*/
@Builder
@EqualsAndHashCode(doNotUseGetters = true) | // Path: src/main/java/nl/tudelft/ewi/gitolite/objects/Identifiable.java
// public interface Identifiable extends Comparable<Identifiable>, Serializable {
//
// String getPattern();
//
// @Override
// default int compareTo(Identifiable o) {
// return getPattern().compareTo(o.getPattern());
// }
//
// }
//
// Path: src/main/java/nl/tudelft/ewi/gitolite/objects/Identifier.java
// @Value
// public class Identifier implements Identifiable {
//
// /**
// * The name for the identifier
// */
// private final String pattern;
//
// private final static WeakHashMap<String, WeakReference<Identifier>> identifiableMap = new WeakHashMap<>();
//
// /**
// * Get an identifier. As {@code Identifiers} should be immutable, they are stored in a
// * {@code WeakHashMap} for caching purposes. This method tries to find {@code Identifiers}
// * in the cache first, and only creates a new instance if not. Therefore, this method is
// * preferred over using a constructor.
// *
// * @param name Name for the identifier.
// * @return Identifier
// */
// public static Identifier valueOf(String name) {
// WeakReference<Identifier> ref = identifiableMap.get(name);
// Identifier identifiable;
// if(ref == null || (identifiable = ref.get()) == null) {
// identifiable = new Identifier(name);
// identifiableMap.put(name, new WeakReference<>(identifiable));
// }
// return identifiable;
// }
//
// }
//
// Path: src/main/java/nl/tudelft/ewi/gitolite/util/RecursiveStreamingGroup.java
// public interface RecursiveStreamingGroup<R extends RecursiveStreamingGroup<? extends StreamingGroup, ? extends T>, T> extends StreamingGroup<T> {
//
// /**
// * @return the own members for this group, excluding the recursive members inherited from the groups.
// */
// Stream<T> getOwnMembersStream();
//
// /**
// * @return the groups in this group.
// */
// Stream<R> getOwnGroupsStream();
//
// /**
// * Add a group to this group.
// * @param group Group to add
// */
// void add(R group);
//
// /**
// * @return the members inherited from the groups.
// */
// default Stream<T> getRecursiveInheritedStream() {
// return getOwnGroupsStream().flatMap(StreamingGroup::getMembersStream);
// }
//
// @Override
// default Stream<T> getMembersStream() {
// return Stream.concat(getRecursiveInheritedStream(), getOwnMembersStream());
// }
//
// }
// Path: src/main/java/nl/tudelft/ewi/gitolite/parser/rules/InlineUserGroup.java
import com.google.common.collect.Lists;
import lombok.Builder;
import lombok.EqualsAndHashCode;
import com.google.common.base.Joiner;
import lombok.Singular;
import nl.tudelft.ewi.gitolite.objects.Identifiable;
import nl.tudelft.ewi.gitolite.objects.Identifier;
import nl.tudelft.ewi.gitolite.util.RecursiveStreamingGroup;
import java.io.IOException;
import java.io.Writer;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
import java.util.function.Predicate;
import java.util.stream.Stream;
package nl.tudelft.ewi.gitolite.parser.rules;
/**
* @author Jan-Willem Gmelig Meyling
*/
@Builder
@EqualsAndHashCode(doNotUseGetters = true) | public class InlineUserGroup implements RecursiveStreamingGroup<GroupRule, Identifier>, Writable { |
devhub-tud/Java-Gitolite-Manager | src/main/java/nl/tudelft/ewi/gitolite/parser/rules/InlineUserGroup.java | // Path: src/main/java/nl/tudelft/ewi/gitolite/objects/Identifiable.java
// public interface Identifiable extends Comparable<Identifiable>, Serializable {
//
// String getPattern();
//
// @Override
// default int compareTo(Identifiable o) {
// return getPattern().compareTo(o.getPattern());
// }
//
// }
//
// Path: src/main/java/nl/tudelft/ewi/gitolite/objects/Identifier.java
// @Value
// public class Identifier implements Identifiable {
//
// /**
// * The name for the identifier
// */
// private final String pattern;
//
// private final static WeakHashMap<String, WeakReference<Identifier>> identifiableMap = new WeakHashMap<>();
//
// /**
// * Get an identifier. As {@code Identifiers} should be immutable, they are stored in a
// * {@code WeakHashMap} for caching purposes. This method tries to find {@code Identifiers}
// * in the cache first, and only creates a new instance if not. Therefore, this method is
// * preferred over using a constructor.
// *
// * @param name Name for the identifier.
// * @return Identifier
// */
// public static Identifier valueOf(String name) {
// WeakReference<Identifier> ref = identifiableMap.get(name);
// Identifier identifiable;
// if(ref == null || (identifiable = ref.get()) == null) {
// identifiable = new Identifier(name);
// identifiableMap.put(name, new WeakReference<>(identifiable));
// }
// return identifiable;
// }
//
// }
//
// Path: src/main/java/nl/tudelft/ewi/gitolite/util/RecursiveStreamingGroup.java
// public interface RecursiveStreamingGroup<R extends RecursiveStreamingGroup<? extends StreamingGroup, ? extends T>, T> extends StreamingGroup<T> {
//
// /**
// * @return the own members for this group, excluding the recursive members inherited from the groups.
// */
// Stream<T> getOwnMembersStream();
//
// /**
// * @return the groups in this group.
// */
// Stream<R> getOwnGroupsStream();
//
// /**
// * Add a group to this group.
// * @param group Group to add
// */
// void add(R group);
//
// /**
// * @return the members inherited from the groups.
// */
// default Stream<T> getRecursiveInheritedStream() {
// return getOwnGroupsStream().flatMap(StreamingGroup::getMembersStream);
// }
//
// @Override
// default Stream<T> getMembersStream() {
// return Stream.concat(getRecursiveInheritedStream(), getOwnMembersStream());
// }
//
// }
| import com.google.common.collect.Lists;
import lombok.Builder;
import lombok.EqualsAndHashCode;
import com.google.common.base.Joiner;
import lombok.Singular;
import nl.tudelft.ewi.gitolite.objects.Identifiable;
import nl.tudelft.ewi.gitolite.objects.Identifier;
import nl.tudelft.ewi.gitolite.util.RecursiveStreamingGroup;
import java.io.IOException;
import java.io.Writer;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
import java.util.function.Predicate;
import java.util.stream.Stream; | package nl.tudelft.ewi.gitolite.parser.rules;
/**
* @author Jan-Willem Gmelig Meyling
*/
@Builder
@EqualsAndHashCode(doNotUseGetters = true) | // Path: src/main/java/nl/tudelft/ewi/gitolite/objects/Identifiable.java
// public interface Identifiable extends Comparable<Identifiable>, Serializable {
//
// String getPattern();
//
// @Override
// default int compareTo(Identifiable o) {
// return getPattern().compareTo(o.getPattern());
// }
//
// }
//
// Path: src/main/java/nl/tudelft/ewi/gitolite/objects/Identifier.java
// @Value
// public class Identifier implements Identifiable {
//
// /**
// * The name for the identifier
// */
// private final String pattern;
//
// private final static WeakHashMap<String, WeakReference<Identifier>> identifiableMap = new WeakHashMap<>();
//
// /**
// * Get an identifier. As {@code Identifiers} should be immutable, they are stored in a
// * {@code WeakHashMap} for caching purposes. This method tries to find {@code Identifiers}
// * in the cache first, and only creates a new instance if not. Therefore, this method is
// * preferred over using a constructor.
// *
// * @param name Name for the identifier.
// * @return Identifier
// */
// public static Identifier valueOf(String name) {
// WeakReference<Identifier> ref = identifiableMap.get(name);
// Identifier identifiable;
// if(ref == null || (identifiable = ref.get()) == null) {
// identifiable = new Identifier(name);
// identifiableMap.put(name, new WeakReference<>(identifiable));
// }
// return identifiable;
// }
//
// }
//
// Path: src/main/java/nl/tudelft/ewi/gitolite/util/RecursiveStreamingGroup.java
// public interface RecursiveStreamingGroup<R extends RecursiveStreamingGroup<? extends StreamingGroup, ? extends T>, T> extends StreamingGroup<T> {
//
// /**
// * @return the own members for this group, excluding the recursive members inherited from the groups.
// */
// Stream<T> getOwnMembersStream();
//
// /**
// * @return the groups in this group.
// */
// Stream<R> getOwnGroupsStream();
//
// /**
// * Add a group to this group.
// * @param group Group to add
// */
// void add(R group);
//
// /**
// * @return the members inherited from the groups.
// */
// default Stream<T> getRecursiveInheritedStream() {
// return getOwnGroupsStream().flatMap(StreamingGroup::getMembersStream);
// }
//
// @Override
// default Stream<T> getMembersStream() {
// return Stream.concat(getRecursiveInheritedStream(), getOwnMembersStream());
// }
//
// }
// Path: src/main/java/nl/tudelft/ewi/gitolite/parser/rules/InlineUserGroup.java
import com.google.common.collect.Lists;
import lombok.Builder;
import lombok.EqualsAndHashCode;
import com.google.common.base.Joiner;
import lombok.Singular;
import nl.tudelft.ewi.gitolite.objects.Identifiable;
import nl.tudelft.ewi.gitolite.objects.Identifier;
import nl.tudelft.ewi.gitolite.util.RecursiveStreamingGroup;
import java.io.IOException;
import java.io.Writer;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
import java.util.function.Predicate;
import java.util.stream.Stream;
package nl.tudelft.ewi.gitolite.parser.rules;
/**
* @author Jan-Willem Gmelig Meyling
*/
@Builder
@EqualsAndHashCode(doNotUseGetters = true) | public class InlineUserGroup implements RecursiveStreamingGroup<GroupRule, Identifier>, Writable { |
devhub-tud/Java-Gitolite-Manager | src/main/java/nl/tudelft/ewi/gitolite/parser/rules/InlineUserGroup.java | // Path: src/main/java/nl/tudelft/ewi/gitolite/objects/Identifiable.java
// public interface Identifiable extends Comparable<Identifiable>, Serializable {
//
// String getPattern();
//
// @Override
// default int compareTo(Identifiable o) {
// return getPattern().compareTo(o.getPattern());
// }
//
// }
//
// Path: src/main/java/nl/tudelft/ewi/gitolite/objects/Identifier.java
// @Value
// public class Identifier implements Identifiable {
//
// /**
// * The name for the identifier
// */
// private final String pattern;
//
// private final static WeakHashMap<String, WeakReference<Identifier>> identifiableMap = new WeakHashMap<>();
//
// /**
// * Get an identifier. As {@code Identifiers} should be immutable, they are stored in a
// * {@code WeakHashMap} for caching purposes. This method tries to find {@code Identifiers}
// * in the cache first, and only creates a new instance if not. Therefore, this method is
// * preferred over using a constructor.
// *
// * @param name Name for the identifier.
// * @return Identifier
// */
// public static Identifier valueOf(String name) {
// WeakReference<Identifier> ref = identifiableMap.get(name);
// Identifier identifiable;
// if(ref == null || (identifiable = ref.get()) == null) {
// identifiable = new Identifier(name);
// identifiableMap.put(name, new WeakReference<>(identifiable));
// }
// return identifiable;
// }
//
// }
//
// Path: src/main/java/nl/tudelft/ewi/gitolite/util/RecursiveStreamingGroup.java
// public interface RecursiveStreamingGroup<R extends RecursiveStreamingGroup<? extends StreamingGroup, ? extends T>, T> extends StreamingGroup<T> {
//
// /**
// * @return the own members for this group, excluding the recursive members inherited from the groups.
// */
// Stream<T> getOwnMembersStream();
//
// /**
// * @return the groups in this group.
// */
// Stream<R> getOwnGroupsStream();
//
// /**
// * Add a group to this group.
// * @param group Group to add
// */
// void add(R group);
//
// /**
// * @return the members inherited from the groups.
// */
// default Stream<T> getRecursiveInheritedStream() {
// return getOwnGroupsStream().flatMap(StreamingGroup::getMembersStream);
// }
//
// @Override
// default Stream<T> getMembersStream() {
// return Stream.concat(getRecursiveInheritedStream(), getOwnMembersStream());
// }
//
// }
| import com.google.common.collect.Lists;
import lombok.Builder;
import lombok.EqualsAndHashCode;
import com.google.common.base.Joiner;
import lombok.Singular;
import nl.tudelft.ewi.gitolite.objects.Identifiable;
import nl.tudelft.ewi.gitolite.objects.Identifier;
import nl.tudelft.ewi.gitolite.util.RecursiveStreamingGroup;
import java.io.IOException;
import java.io.Writer;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
import java.util.function.Predicate;
import java.util.stream.Stream; |
@Override
public boolean removeAll(Collection<?> c) {
// Intended inclusive-OR
return members.removeAll(c) | groups.removeAll(c);
}
@Override
public boolean retainAll(Collection<?> c) {
return members.retainAll(c) | groups.retainAll(c);
}
@Override
public void clear() {
groups.clear();
members.clear();
}
@Override
public boolean removeIf(Predicate<? super Identifier> filter) {
return members.removeIf(filter);
}
@Override
public void write(Writer writer) throws IOException {
writer.write(writeString());
}
private String writeString() {
return Joiner.on(' ').join(Stream.concat(getOwnGroupsStream(), getOwnMembersStream()) | // Path: src/main/java/nl/tudelft/ewi/gitolite/objects/Identifiable.java
// public interface Identifiable extends Comparable<Identifiable>, Serializable {
//
// String getPattern();
//
// @Override
// default int compareTo(Identifiable o) {
// return getPattern().compareTo(o.getPattern());
// }
//
// }
//
// Path: src/main/java/nl/tudelft/ewi/gitolite/objects/Identifier.java
// @Value
// public class Identifier implements Identifiable {
//
// /**
// * The name for the identifier
// */
// private final String pattern;
//
// private final static WeakHashMap<String, WeakReference<Identifier>> identifiableMap = new WeakHashMap<>();
//
// /**
// * Get an identifier. As {@code Identifiers} should be immutable, they are stored in a
// * {@code WeakHashMap} for caching purposes. This method tries to find {@code Identifiers}
// * in the cache first, and only creates a new instance if not. Therefore, this method is
// * preferred over using a constructor.
// *
// * @param name Name for the identifier.
// * @return Identifier
// */
// public static Identifier valueOf(String name) {
// WeakReference<Identifier> ref = identifiableMap.get(name);
// Identifier identifiable;
// if(ref == null || (identifiable = ref.get()) == null) {
// identifiable = new Identifier(name);
// identifiableMap.put(name, new WeakReference<>(identifiable));
// }
// return identifiable;
// }
//
// }
//
// Path: src/main/java/nl/tudelft/ewi/gitolite/util/RecursiveStreamingGroup.java
// public interface RecursiveStreamingGroup<R extends RecursiveStreamingGroup<? extends StreamingGroup, ? extends T>, T> extends StreamingGroup<T> {
//
// /**
// * @return the own members for this group, excluding the recursive members inherited from the groups.
// */
// Stream<T> getOwnMembersStream();
//
// /**
// * @return the groups in this group.
// */
// Stream<R> getOwnGroupsStream();
//
// /**
// * Add a group to this group.
// * @param group Group to add
// */
// void add(R group);
//
// /**
// * @return the members inherited from the groups.
// */
// default Stream<T> getRecursiveInheritedStream() {
// return getOwnGroupsStream().flatMap(StreamingGroup::getMembersStream);
// }
//
// @Override
// default Stream<T> getMembersStream() {
// return Stream.concat(getRecursiveInheritedStream(), getOwnMembersStream());
// }
//
// }
// Path: src/main/java/nl/tudelft/ewi/gitolite/parser/rules/InlineUserGroup.java
import com.google.common.collect.Lists;
import lombok.Builder;
import lombok.EqualsAndHashCode;
import com.google.common.base.Joiner;
import lombok.Singular;
import nl.tudelft.ewi.gitolite.objects.Identifiable;
import nl.tudelft.ewi.gitolite.objects.Identifier;
import nl.tudelft.ewi.gitolite.util.RecursiveStreamingGroup;
import java.io.IOException;
import java.io.Writer;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
import java.util.function.Predicate;
import java.util.stream.Stream;
@Override
public boolean removeAll(Collection<?> c) {
// Intended inclusive-OR
return members.removeAll(c) | groups.removeAll(c);
}
@Override
public boolean retainAll(Collection<?> c) {
return members.retainAll(c) | groups.retainAll(c);
}
@Override
public void clear() {
groups.clear();
members.clear();
}
@Override
public boolean removeIf(Predicate<? super Identifier> filter) {
return members.removeIf(filter);
}
@Override
public void write(Writer writer) throws IOException {
writer.write(writeString());
}
private String writeString() {
return Joiner.on(' ').join(Stream.concat(getOwnGroupsStream(), getOwnMembersStream()) | .map(Identifiable::getPattern) |
devhub-tud/Java-Gitolite-Manager | src/main/java/nl/tudelft/ewi/gitolite/parser/rules/RepositoryRule.java | // Path: src/main/java/nl/tudelft/ewi/gitolite/objects/Identifiable.java
// public interface Identifiable extends Comparable<Identifiable>, Serializable {
//
// String getPattern();
//
// @Override
// default int compareTo(Identifiable o) {
// return getPattern().compareTo(o.getPattern());
// }
//
// }
//
// Path: src/main/java/nl/tudelft/ewi/gitolite/objects/Identifier.java
// @Value
// public class Identifier implements Identifiable {
//
// /**
// * The name for the identifier
// */
// private final String pattern;
//
// private final static WeakHashMap<String, WeakReference<Identifier>> identifiableMap = new WeakHashMap<>();
//
// /**
// * Get an identifier. As {@code Identifiers} should be immutable, they are stored in a
// * {@code WeakHashMap} for caching purposes. This method tries to find {@code Identifiers}
// * in the cache first, and only creates a new instance if not. Therefore, this method is
// * preferred over using a constructor.
// *
// * @param name Name for the identifier.
// * @return Identifier
// */
// public static Identifier valueOf(String name) {
// WeakReference<Identifier> ref = identifiableMap.get(name);
// Identifier identifiable;
// if(ref == null || (identifiable = ref.get()) == null) {
// identifiable = new Identifier(name);
// identifiableMap.put(name, new WeakReference<>(identifiable));
// }
// return identifiable;
// }
//
// }
| import com.google.common.collect.Lists;
import lombok.Builder;
import lombok.EqualsAndHashCode;
import lombok.Singular;
import lombok.SneakyThrows;
import lombok.Value;
import nl.tudelft.ewi.gitolite.objects.Identifiable;
import nl.tudelft.ewi.gitolite.objects.Identifier;
import java.io.IOException;
import java.io.StringWriter;
import java.io.Writer;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.List; | package nl.tudelft.ewi.gitolite.parser.rules;
/**
* @author Jan-Willem Gmelig Meyling
*/
@Value
@Builder
@EqualsAndHashCode
public class RepositoryRule implements Rule {
/**
* Regex pattern for the repositories.
* Due to projects like gtk+, the + character is now considered a valid character for an ordinary repo.
* Therefore, a regex like foo/.+ does not look like a regex to gitolite. Use foo/..* if you want that.
* Also, ..* by itself is not considered a valid repo regex. Try [a-zA-Z0-9].*. CREATOR/..* will also work.
*/
@Singular | // Path: src/main/java/nl/tudelft/ewi/gitolite/objects/Identifiable.java
// public interface Identifiable extends Comparable<Identifiable>, Serializable {
//
// String getPattern();
//
// @Override
// default int compareTo(Identifiable o) {
// return getPattern().compareTo(o.getPattern());
// }
//
// }
//
// Path: src/main/java/nl/tudelft/ewi/gitolite/objects/Identifier.java
// @Value
// public class Identifier implements Identifiable {
//
// /**
// * The name for the identifier
// */
// private final String pattern;
//
// private final static WeakHashMap<String, WeakReference<Identifier>> identifiableMap = new WeakHashMap<>();
//
// /**
// * Get an identifier. As {@code Identifiers} should be immutable, they are stored in a
// * {@code WeakHashMap} for caching purposes. This method tries to find {@code Identifiers}
// * in the cache first, and only creates a new instance if not. Therefore, this method is
// * preferred over using a constructor.
// *
// * @param name Name for the identifier.
// * @return Identifier
// */
// public static Identifier valueOf(String name) {
// WeakReference<Identifier> ref = identifiableMap.get(name);
// Identifier identifiable;
// if(ref == null || (identifiable = ref.get()) == null) {
// identifiable = new Identifier(name);
// identifiableMap.put(name, new WeakReference<>(identifiable));
// }
// return identifiable;
// }
//
// }
// Path: src/main/java/nl/tudelft/ewi/gitolite/parser/rules/RepositoryRule.java
import com.google.common.collect.Lists;
import lombok.Builder;
import lombok.EqualsAndHashCode;
import lombok.Singular;
import lombok.SneakyThrows;
import lombok.Value;
import nl.tudelft.ewi.gitolite.objects.Identifiable;
import nl.tudelft.ewi.gitolite.objects.Identifier;
import java.io.IOException;
import java.io.StringWriter;
import java.io.Writer;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
package nl.tudelft.ewi.gitolite.parser.rules;
/**
* @author Jan-Willem Gmelig Meyling
*/
@Value
@Builder
@EqualsAndHashCode
public class RepositoryRule implements Rule {
/**
* Regex pattern for the repositories.
* Due to projects like gtk+, the + character is now considered a valid character for an ordinary repo.
* Therefore, a regex like foo/.+ does not look like a regex to gitolite. Use foo/..* if you want that.
* Also, ..* by itself is not considered a valid repo regex. Try [a-zA-Z0-9].*. CREATOR/..* will also work.
*/
@Singular | private final List<Identifiable> identifiables; |
devhub-tud/Java-Gitolite-Manager | src/main/java/nl/tudelft/ewi/gitolite/parser/rules/RepositoryRule.java | // Path: src/main/java/nl/tudelft/ewi/gitolite/objects/Identifiable.java
// public interface Identifiable extends Comparable<Identifiable>, Serializable {
//
// String getPattern();
//
// @Override
// default int compareTo(Identifiable o) {
// return getPattern().compareTo(o.getPattern());
// }
//
// }
//
// Path: src/main/java/nl/tudelft/ewi/gitolite/objects/Identifier.java
// @Value
// public class Identifier implements Identifiable {
//
// /**
// * The name for the identifier
// */
// private final String pattern;
//
// private final static WeakHashMap<String, WeakReference<Identifier>> identifiableMap = new WeakHashMap<>();
//
// /**
// * Get an identifier. As {@code Identifiers} should be immutable, they are stored in a
// * {@code WeakHashMap} for caching purposes. This method tries to find {@code Identifiers}
// * in the cache first, and only creates a new instance if not. Therefore, this method is
// * preferred over using a constructor.
// *
// * @param name Name for the identifier.
// * @return Identifier
// */
// public static Identifier valueOf(String name) {
// WeakReference<Identifier> ref = identifiableMap.get(name);
// Identifier identifiable;
// if(ref == null || (identifiable = ref.get()) == null) {
// identifiable = new Identifier(name);
// identifiableMap.put(name, new WeakReference<>(identifiable));
// }
// return identifiable;
// }
//
// }
| import com.google.common.collect.Lists;
import lombok.Builder;
import lombok.EqualsAndHashCode;
import lombok.Singular;
import lombok.SneakyThrows;
import lombok.Value;
import nl.tudelft.ewi.gitolite.objects.Identifiable;
import nl.tudelft.ewi.gitolite.objects.Identifier;
import java.io.IOException;
import java.io.StringWriter;
import java.io.Writer;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.List; | package nl.tudelft.ewi.gitolite.parser.rules;
/**
* @author Jan-Willem Gmelig Meyling
*/
@Value
@Builder
@EqualsAndHashCode
public class RepositoryRule implements Rule {
/**
* Regex pattern for the repositories.
* Due to projects like gtk+, the + character is now considered a valid character for an ordinary repo.
* Therefore, a regex like foo/.+ does not look like a regex to gitolite. Use foo/..* if you want that.
* Also, ..* by itself is not considered a valid repo regex. Try [a-zA-Z0-9].*. CREATOR/..* will also work.
*/
@Singular
private final List<Identifiable> identifiables;
/**
* Rules active for the repositories that match this pattern.
*/
@Singular
private final List<AccessRule> rules;
/**
* Configuration keys.
*/
@Singular
private final List<ConfigKey> configKeys;
/**
* Helper method to quickly initialize rules in the following way:
*
* {@code
* <pre>
* new RepositoryRuleBlock("foo", new RepositoryRule(RW_PLUS, members);
* </pre>}
*
* @param pattern Pattern to use.
* @param rules Rules to use.
*/
public RepositoryRule(String pattern, AccessRule... rules) { | // Path: src/main/java/nl/tudelft/ewi/gitolite/objects/Identifiable.java
// public interface Identifiable extends Comparable<Identifiable>, Serializable {
//
// String getPattern();
//
// @Override
// default int compareTo(Identifiable o) {
// return getPattern().compareTo(o.getPattern());
// }
//
// }
//
// Path: src/main/java/nl/tudelft/ewi/gitolite/objects/Identifier.java
// @Value
// public class Identifier implements Identifiable {
//
// /**
// * The name for the identifier
// */
// private final String pattern;
//
// private final static WeakHashMap<String, WeakReference<Identifier>> identifiableMap = new WeakHashMap<>();
//
// /**
// * Get an identifier. As {@code Identifiers} should be immutable, they are stored in a
// * {@code WeakHashMap} for caching purposes. This method tries to find {@code Identifiers}
// * in the cache first, and only creates a new instance if not. Therefore, this method is
// * preferred over using a constructor.
// *
// * @param name Name for the identifier.
// * @return Identifier
// */
// public static Identifier valueOf(String name) {
// WeakReference<Identifier> ref = identifiableMap.get(name);
// Identifier identifiable;
// if(ref == null || (identifiable = ref.get()) == null) {
// identifiable = new Identifier(name);
// identifiableMap.put(name, new WeakReference<>(identifiable));
// }
// return identifiable;
// }
//
// }
// Path: src/main/java/nl/tudelft/ewi/gitolite/parser/rules/RepositoryRule.java
import com.google.common.collect.Lists;
import lombok.Builder;
import lombok.EqualsAndHashCode;
import lombok.Singular;
import lombok.SneakyThrows;
import lombok.Value;
import nl.tudelft.ewi.gitolite.objects.Identifiable;
import nl.tudelft.ewi.gitolite.objects.Identifier;
import java.io.IOException;
import java.io.StringWriter;
import java.io.Writer;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
package nl.tudelft.ewi.gitolite.parser.rules;
/**
* @author Jan-Willem Gmelig Meyling
*/
@Value
@Builder
@EqualsAndHashCode
public class RepositoryRule implements Rule {
/**
* Regex pattern for the repositories.
* Due to projects like gtk+, the + character is now considered a valid character for an ordinary repo.
* Therefore, a regex like foo/.+ does not look like a regex to gitolite. Use foo/..* if you want that.
* Also, ..* by itself is not considered a valid repo regex. Try [a-zA-Z0-9].*. CREATOR/..* will also work.
*/
@Singular
private final List<Identifiable> identifiables;
/**
* Rules active for the repositories that match this pattern.
*/
@Singular
private final List<AccessRule> rules;
/**
* Configuration keys.
*/
@Singular
private final List<ConfigKey> configKeys;
/**
* Helper method to quickly initialize rules in the following way:
*
* {@code
* <pre>
* new RepositoryRuleBlock("foo", new RepositoryRule(RW_PLUS, members);
* </pre>}
*
* @param pattern Pattern to use.
* @param rules Rules to use.
*/
public RepositoryRule(String pattern, AccessRule... rules) { | this(Collections.singletonList(new Identifier(pattern)), Arrays.asList(rules), Collections.emptyList()); |
devhub-tud/Java-Gitolite-Manager | src/test/java/TestGroupRule.java | // Path: src/main/java/nl/tudelft/ewi/gitolite/parser/rules/GroupRule.java
// @Data
// @Builder
// //@EqualsAndHashCode(doNotUseGetters = true)
// public class GroupRule implements RecursiveAndPrototypeStreamingGroup<GroupRule, Identifier>, Rule, Identifiable {
//
// /**
// * {@code @all} is a special group name that is often convenient to use if you really mean "all repos" or "all users".
// */
// public final static GroupRule ALL = new GroupRule("@all") {
//
// @Override
// public boolean contains(Object value) {
// return true;
// }
//
// @Override
// public String toString() { return "@all"; }
//
// @Override
// public void write(Writer writer) {}
//
// };
//
// @Getter
// private final String pattern;
//
// @Getter
// private GroupRule parent;
//
// @Singular
// private final List<Identifier> members;
//
// @Singular
// private final List<GroupRule> groups;
//
// public GroupRule(final String pattern, final Identifier... members) {
// this(pattern, null, Lists.newArrayList(members), Collections.emptyList());
// }
//
// public GroupRule(final String pattern,
// final GroupRule parent,
// final Collection<? extends Identifier> members,
// final Collection<? extends GroupRule> groups) {
// Preconditions.checkNotNull(pattern);
// Preconditions.checkNotNull(groups);
// Preconditions.checkNotNull(members);
// Preconditions.checkArgument(pattern.matches("^\\@\\w[\\w._\\@+-]+$"), "\"%s\" is not a valid group name", pattern);
//
// this.pattern = pattern;
// this.parent = parent;
// this.groups = Lists.newArrayList(groups);
// this.members = Lists.newArrayList(members);
// }
//
// @Override
// public Stream<Identifier> getOwnMembersStream() {
// return members.stream();
// }
//
// @Override
// public Stream<GroupRule> getOwnGroupsStream() {
// return groups.stream();
// }
//
// @Override
// public void add(GroupRule group) {
// groups.add(group);
// }
//
// @Override
// public boolean remove(Object element) {
// return members.remove(element) | groups.remove(element) | (parent != null && parent.remove(element));
// }
//
// @Override
// public boolean add(Identifier value) {
// return members.add(value);
// }
//
// @Override
// public boolean addAll(Collection<? extends Identifier> c) {
// return members.addAll(c);
// }
//
// @Override
// public boolean removeAll(Collection<?> c) {
// return members.removeAll(c) | groups.removeAll(c);
// }
//
// @Override
// public boolean retainAll(Collection<?> c) {
// return members.retainAll(c) | groups.retainAll(c);
// }
//
// @Override
// public void clear() {
// members.clear();
// groups.clear();
// }
//
// @Override
// public boolean removeIf(Predicate<? super Identifier> filter) {
// return members.removeIf(filter);
// }
//
// @Override
// public void write(Writer writer) throws IOException {
// writer.write(String.format("%-20s= %s\n", pattern, Joiner.on(' ').join(Stream.concat(getOwnGroupsStream(), getOwnMembersStream())
// .map(Identifiable::getPattern)
// .iterator())));
// writer.flush();
// }
//
//
// @Override
// public String toString() {
// return (String.format("%-20s= %s\n", pattern, Joiner.on(' ').join(Stream.concat(getOwnGroupsStream(), getOwnMembersStream())
// .map(Identifiable::getPattern)
// .iterator())));
// }
//
// }
//
// Path: src/main/java/nl/tudelft/ewi/gitolite/objects/Identifiable.java
// public interface Identifiable extends Comparable<Identifiable>, Serializable {
//
// String getPattern();
//
// @Override
// default int compareTo(Identifiable o) {
// return getPattern().compareTo(o.getPattern());
// }
//
// }
//
// Path: src/main/java/nl/tudelft/ewi/gitolite/objects/Identifier.java
// @Value
// public class Identifier implements Identifiable {
//
// /**
// * The name for the identifier
// */
// private final String pattern;
//
// private final static WeakHashMap<String, WeakReference<Identifier>> identifiableMap = new WeakHashMap<>();
//
// /**
// * Get an identifier. As {@code Identifiers} should be immutable, they are stored in a
// * {@code WeakHashMap} for caching purposes. This method tries to find {@code Identifiers}
// * in the cache first, and only creates a new instance if not. Therefore, this method is
// * preferred over using a constructor.
// *
// * @param name Name for the identifier.
// * @return Identifier
// */
// public static Identifier valueOf(String name) {
// WeakReference<Identifier> ref = identifiableMap.get(name);
// Identifier identifiable;
// if(ref == null || (identifiable = ref.get()) == null) {
// identifiable = new Identifier(name);
// identifiableMap.put(name, new WeakReference<>(identifiable));
// }
// return identifiable;
// }
//
// }
| import nl.tudelft.ewi.gitolite.parser.rules.GroupRule;
import nl.tudelft.ewi.gitolite.objects.Identifiable;
import nl.tudelft.ewi.gitolite.objects.Identifier;
import org.junit.Test;
import java.io.IOException;
import java.util.List;
import java.util.stream.Collectors;
import static org.junit.Assert.assertThat;
import static org.hamcrest.Matchers.contains; |
/**
* @author Jan-Willem Gmelig Meyling
*/
public class TestGroupRule {
@Test
public void test1() throws IOException { | // Path: src/main/java/nl/tudelft/ewi/gitolite/parser/rules/GroupRule.java
// @Data
// @Builder
// //@EqualsAndHashCode(doNotUseGetters = true)
// public class GroupRule implements RecursiveAndPrototypeStreamingGroup<GroupRule, Identifier>, Rule, Identifiable {
//
// /**
// * {@code @all} is a special group name that is often convenient to use if you really mean "all repos" or "all users".
// */
// public final static GroupRule ALL = new GroupRule("@all") {
//
// @Override
// public boolean contains(Object value) {
// return true;
// }
//
// @Override
// public String toString() { return "@all"; }
//
// @Override
// public void write(Writer writer) {}
//
// };
//
// @Getter
// private final String pattern;
//
// @Getter
// private GroupRule parent;
//
// @Singular
// private final List<Identifier> members;
//
// @Singular
// private final List<GroupRule> groups;
//
// public GroupRule(final String pattern, final Identifier... members) {
// this(pattern, null, Lists.newArrayList(members), Collections.emptyList());
// }
//
// public GroupRule(final String pattern,
// final GroupRule parent,
// final Collection<? extends Identifier> members,
// final Collection<? extends GroupRule> groups) {
// Preconditions.checkNotNull(pattern);
// Preconditions.checkNotNull(groups);
// Preconditions.checkNotNull(members);
// Preconditions.checkArgument(pattern.matches("^\\@\\w[\\w._\\@+-]+$"), "\"%s\" is not a valid group name", pattern);
//
// this.pattern = pattern;
// this.parent = parent;
// this.groups = Lists.newArrayList(groups);
// this.members = Lists.newArrayList(members);
// }
//
// @Override
// public Stream<Identifier> getOwnMembersStream() {
// return members.stream();
// }
//
// @Override
// public Stream<GroupRule> getOwnGroupsStream() {
// return groups.stream();
// }
//
// @Override
// public void add(GroupRule group) {
// groups.add(group);
// }
//
// @Override
// public boolean remove(Object element) {
// return members.remove(element) | groups.remove(element) | (parent != null && parent.remove(element));
// }
//
// @Override
// public boolean add(Identifier value) {
// return members.add(value);
// }
//
// @Override
// public boolean addAll(Collection<? extends Identifier> c) {
// return members.addAll(c);
// }
//
// @Override
// public boolean removeAll(Collection<?> c) {
// return members.removeAll(c) | groups.removeAll(c);
// }
//
// @Override
// public boolean retainAll(Collection<?> c) {
// return members.retainAll(c) | groups.retainAll(c);
// }
//
// @Override
// public void clear() {
// members.clear();
// groups.clear();
// }
//
// @Override
// public boolean removeIf(Predicate<? super Identifier> filter) {
// return members.removeIf(filter);
// }
//
// @Override
// public void write(Writer writer) throws IOException {
// writer.write(String.format("%-20s= %s\n", pattern, Joiner.on(' ').join(Stream.concat(getOwnGroupsStream(), getOwnMembersStream())
// .map(Identifiable::getPattern)
// .iterator())));
// writer.flush();
// }
//
//
// @Override
// public String toString() {
// return (String.format("%-20s= %s\n", pattern, Joiner.on(' ').join(Stream.concat(getOwnGroupsStream(), getOwnMembersStream())
// .map(Identifiable::getPattern)
// .iterator())));
// }
//
// }
//
// Path: src/main/java/nl/tudelft/ewi/gitolite/objects/Identifiable.java
// public interface Identifiable extends Comparable<Identifiable>, Serializable {
//
// String getPattern();
//
// @Override
// default int compareTo(Identifiable o) {
// return getPattern().compareTo(o.getPattern());
// }
//
// }
//
// Path: src/main/java/nl/tudelft/ewi/gitolite/objects/Identifier.java
// @Value
// public class Identifier implements Identifiable {
//
// /**
// * The name for the identifier
// */
// private final String pattern;
//
// private final static WeakHashMap<String, WeakReference<Identifier>> identifiableMap = new WeakHashMap<>();
//
// /**
// * Get an identifier. As {@code Identifiers} should be immutable, they are stored in a
// * {@code WeakHashMap} for caching purposes. This method tries to find {@code Identifiers}
// * in the cache first, and only creates a new instance if not. Therefore, this method is
// * preferred over using a constructor.
// *
// * @param name Name for the identifier.
// * @return Identifier
// */
// public static Identifier valueOf(String name) {
// WeakReference<Identifier> ref = identifiableMap.get(name);
// Identifier identifiable;
// if(ref == null || (identifiable = ref.get()) == null) {
// identifiable = new Identifier(name);
// identifiableMap.put(name, new WeakReference<>(identifiable));
// }
// return identifiable;
// }
//
// }
// Path: src/test/java/TestGroupRule.java
import nl.tudelft.ewi.gitolite.parser.rules.GroupRule;
import nl.tudelft.ewi.gitolite.objects.Identifiable;
import nl.tudelft.ewi.gitolite.objects.Identifier;
import org.junit.Test;
import java.io.IOException;
import java.util.List;
import java.util.stream.Collectors;
import static org.junit.Assert.assertThat;
import static org.hamcrest.Matchers.contains;
/**
* @author Jan-Willem Gmelig Meyling
*/
public class TestGroupRule {
@Test
public void test1() throws IOException { | Identifier foo = new Identifier("foo"); |
devhub-tud/Java-Gitolite-Manager | src/test/java/TestGroupRule.java | // Path: src/main/java/nl/tudelft/ewi/gitolite/parser/rules/GroupRule.java
// @Data
// @Builder
// //@EqualsAndHashCode(doNotUseGetters = true)
// public class GroupRule implements RecursiveAndPrototypeStreamingGroup<GroupRule, Identifier>, Rule, Identifiable {
//
// /**
// * {@code @all} is a special group name that is often convenient to use if you really mean "all repos" or "all users".
// */
// public final static GroupRule ALL = new GroupRule("@all") {
//
// @Override
// public boolean contains(Object value) {
// return true;
// }
//
// @Override
// public String toString() { return "@all"; }
//
// @Override
// public void write(Writer writer) {}
//
// };
//
// @Getter
// private final String pattern;
//
// @Getter
// private GroupRule parent;
//
// @Singular
// private final List<Identifier> members;
//
// @Singular
// private final List<GroupRule> groups;
//
// public GroupRule(final String pattern, final Identifier... members) {
// this(pattern, null, Lists.newArrayList(members), Collections.emptyList());
// }
//
// public GroupRule(final String pattern,
// final GroupRule parent,
// final Collection<? extends Identifier> members,
// final Collection<? extends GroupRule> groups) {
// Preconditions.checkNotNull(pattern);
// Preconditions.checkNotNull(groups);
// Preconditions.checkNotNull(members);
// Preconditions.checkArgument(pattern.matches("^\\@\\w[\\w._\\@+-]+$"), "\"%s\" is not a valid group name", pattern);
//
// this.pattern = pattern;
// this.parent = parent;
// this.groups = Lists.newArrayList(groups);
// this.members = Lists.newArrayList(members);
// }
//
// @Override
// public Stream<Identifier> getOwnMembersStream() {
// return members.stream();
// }
//
// @Override
// public Stream<GroupRule> getOwnGroupsStream() {
// return groups.stream();
// }
//
// @Override
// public void add(GroupRule group) {
// groups.add(group);
// }
//
// @Override
// public boolean remove(Object element) {
// return members.remove(element) | groups.remove(element) | (parent != null && parent.remove(element));
// }
//
// @Override
// public boolean add(Identifier value) {
// return members.add(value);
// }
//
// @Override
// public boolean addAll(Collection<? extends Identifier> c) {
// return members.addAll(c);
// }
//
// @Override
// public boolean removeAll(Collection<?> c) {
// return members.removeAll(c) | groups.removeAll(c);
// }
//
// @Override
// public boolean retainAll(Collection<?> c) {
// return members.retainAll(c) | groups.retainAll(c);
// }
//
// @Override
// public void clear() {
// members.clear();
// groups.clear();
// }
//
// @Override
// public boolean removeIf(Predicate<? super Identifier> filter) {
// return members.removeIf(filter);
// }
//
// @Override
// public void write(Writer writer) throws IOException {
// writer.write(String.format("%-20s= %s\n", pattern, Joiner.on(' ').join(Stream.concat(getOwnGroupsStream(), getOwnMembersStream())
// .map(Identifiable::getPattern)
// .iterator())));
// writer.flush();
// }
//
//
// @Override
// public String toString() {
// return (String.format("%-20s= %s\n", pattern, Joiner.on(' ').join(Stream.concat(getOwnGroupsStream(), getOwnMembersStream())
// .map(Identifiable::getPattern)
// .iterator())));
// }
//
// }
//
// Path: src/main/java/nl/tudelft/ewi/gitolite/objects/Identifiable.java
// public interface Identifiable extends Comparable<Identifiable>, Serializable {
//
// String getPattern();
//
// @Override
// default int compareTo(Identifiable o) {
// return getPattern().compareTo(o.getPattern());
// }
//
// }
//
// Path: src/main/java/nl/tudelft/ewi/gitolite/objects/Identifier.java
// @Value
// public class Identifier implements Identifiable {
//
// /**
// * The name for the identifier
// */
// private final String pattern;
//
// private final static WeakHashMap<String, WeakReference<Identifier>> identifiableMap = new WeakHashMap<>();
//
// /**
// * Get an identifier. As {@code Identifiers} should be immutable, they are stored in a
// * {@code WeakHashMap} for caching purposes. This method tries to find {@code Identifiers}
// * in the cache first, and only creates a new instance if not. Therefore, this method is
// * preferred over using a constructor.
// *
// * @param name Name for the identifier.
// * @return Identifier
// */
// public static Identifier valueOf(String name) {
// WeakReference<Identifier> ref = identifiableMap.get(name);
// Identifier identifiable;
// if(ref == null || (identifiable = ref.get()) == null) {
// identifiable = new Identifier(name);
// identifiableMap.put(name, new WeakReference<>(identifiable));
// }
// return identifiable;
// }
//
// }
| import nl.tudelft.ewi.gitolite.parser.rules.GroupRule;
import nl.tudelft.ewi.gitolite.objects.Identifiable;
import nl.tudelft.ewi.gitolite.objects.Identifier;
import org.junit.Test;
import java.io.IOException;
import java.util.List;
import java.util.stream.Collectors;
import static org.junit.Assert.assertThat;
import static org.hamcrest.Matchers.contains; |
/**
* @author Jan-Willem Gmelig Meyling
*/
public class TestGroupRule {
@Test
public void test1() throws IOException {
Identifier foo = new Identifier("foo");
Identifier bar = new Identifier("bar");
| // Path: src/main/java/nl/tudelft/ewi/gitolite/parser/rules/GroupRule.java
// @Data
// @Builder
// //@EqualsAndHashCode(doNotUseGetters = true)
// public class GroupRule implements RecursiveAndPrototypeStreamingGroup<GroupRule, Identifier>, Rule, Identifiable {
//
// /**
// * {@code @all} is a special group name that is often convenient to use if you really mean "all repos" or "all users".
// */
// public final static GroupRule ALL = new GroupRule("@all") {
//
// @Override
// public boolean contains(Object value) {
// return true;
// }
//
// @Override
// public String toString() { return "@all"; }
//
// @Override
// public void write(Writer writer) {}
//
// };
//
// @Getter
// private final String pattern;
//
// @Getter
// private GroupRule parent;
//
// @Singular
// private final List<Identifier> members;
//
// @Singular
// private final List<GroupRule> groups;
//
// public GroupRule(final String pattern, final Identifier... members) {
// this(pattern, null, Lists.newArrayList(members), Collections.emptyList());
// }
//
// public GroupRule(final String pattern,
// final GroupRule parent,
// final Collection<? extends Identifier> members,
// final Collection<? extends GroupRule> groups) {
// Preconditions.checkNotNull(pattern);
// Preconditions.checkNotNull(groups);
// Preconditions.checkNotNull(members);
// Preconditions.checkArgument(pattern.matches("^\\@\\w[\\w._\\@+-]+$"), "\"%s\" is not a valid group name", pattern);
//
// this.pattern = pattern;
// this.parent = parent;
// this.groups = Lists.newArrayList(groups);
// this.members = Lists.newArrayList(members);
// }
//
// @Override
// public Stream<Identifier> getOwnMembersStream() {
// return members.stream();
// }
//
// @Override
// public Stream<GroupRule> getOwnGroupsStream() {
// return groups.stream();
// }
//
// @Override
// public void add(GroupRule group) {
// groups.add(group);
// }
//
// @Override
// public boolean remove(Object element) {
// return members.remove(element) | groups.remove(element) | (parent != null && parent.remove(element));
// }
//
// @Override
// public boolean add(Identifier value) {
// return members.add(value);
// }
//
// @Override
// public boolean addAll(Collection<? extends Identifier> c) {
// return members.addAll(c);
// }
//
// @Override
// public boolean removeAll(Collection<?> c) {
// return members.removeAll(c) | groups.removeAll(c);
// }
//
// @Override
// public boolean retainAll(Collection<?> c) {
// return members.retainAll(c) | groups.retainAll(c);
// }
//
// @Override
// public void clear() {
// members.clear();
// groups.clear();
// }
//
// @Override
// public boolean removeIf(Predicate<? super Identifier> filter) {
// return members.removeIf(filter);
// }
//
// @Override
// public void write(Writer writer) throws IOException {
// writer.write(String.format("%-20s= %s\n", pattern, Joiner.on(' ').join(Stream.concat(getOwnGroupsStream(), getOwnMembersStream())
// .map(Identifiable::getPattern)
// .iterator())));
// writer.flush();
// }
//
//
// @Override
// public String toString() {
// return (String.format("%-20s= %s\n", pattern, Joiner.on(' ').join(Stream.concat(getOwnGroupsStream(), getOwnMembersStream())
// .map(Identifiable::getPattern)
// .iterator())));
// }
//
// }
//
// Path: src/main/java/nl/tudelft/ewi/gitolite/objects/Identifiable.java
// public interface Identifiable extends Comparable<Identifiable>, Serializable {
//
// String getPattern();
//
// @Override
// default int compareTo(Identifiable o) {
// return getPattern().compareTo(o.getPattern());
// }
//
// }
//
// Path: src/main/java/nl/tudelft/ewi/gitolite/objects/Identifier.java
// @Value
// public class Identifier implements Identifiable {
//
// /**
// * The name for the identifier
// */
// private final String pattern;
//
// private final static WeakHashMap<String, WeakReference<Identifier>> identifiableMap = new WeakHashMap<>();
//
// /**
// * Get an identifier. As {@code Identifiers} should be immutable, they are stored in a
// * {@code WeakHashMap} for caching purposes. This method tries to find {@code Identifiers}
// * in the cache first, and only creates a new instance if not. Therefore, this method is
// * preferred over using a constructor.
// *
// * @param name Name for the identifier.
// * @return Identifier
// */
// public static Identifier valueOf(String name) {
// WeakReference<Identifier> ref = identifiableMap.get(name);
// Identifier identifiable;
// if(ref == null || (identifiable = ref.get()) == null) {
// identifiable = new Identifier(name);
// identifiableMap.put(name, new WeakReference<>(identifiable));
// }
// return identifiable;
// }
//
// }
// Path: src/test/java/TestGroupRule.java
import nl.tudelft.ewi.gitolite.parser.rules.GroupRule;
import nl.tudelft.ewi.gitolite.objects.Identifiable;
import nl.tudelft.ewi.gitolite.objects.Identifier;
import org.junit.Test;
import java.io.IOException;
import java.util.List;
import java.util.stream.Collectors;
import static org.junit.Assert.assertThat;
import static org.hamcrest.Matchers.contains;
/**
* @author Jan-Willem Gmelig Meyling
*/
public class TestGroupRule {
@Test
public void test1() throws IOException {
Identifier foo = new Identifier("foo");
Identifier bar = new Identifier("bar");
| GroupRule test = GroupRule.builder() |
devhub-tud/Java-Gitolite-Manager | src/main/java/nl/tudelft/ewi/gitolite/parser/rules/GroupRule.java | // Path: src/main/java/nl/tudelft/ewi/gitolite/objects/Identifiable.java
// public interface Identifiable extends Comparable<Identifiable>, Serializable {
//
// String getPattern();
//
// @Override
// default int compareTo(Identifiable o) {
// return getPattern().compareTo(o.getPattern());
// }
//
// }
//
// Path: src/main/java/nl/tudelft/ewi/gitolite/objects/Identifier.java
// @Value
// public class Identifier implements Identifiable {
//
// /**
// * The name for the identifier
// */
// private final String pattern;
//
// private final static WeakHashMap<String, WeakReference<Identifier>> identifiableMap = new WeakHashMap<>();
//
// /**
// * Get an identifier. As {@code Identifiers} should be immutable, they are stored in a
// * {@code WeakHashMap} for caching purposes. This method tries to find {@code Identifiers}
// * in the cache first, and only creates a new instance if not. Therefore, this method is
// * preferred over using a constructor.
// *
// * @param name Name for the identifier.
// * @return Identifier
// */
// public static Identifier valueOf(String name) {
// WeakReference<Identifier> ref = identifiableMap.get(name);
// Identifier identifiable;
// if(ref == null || (identifiable = ref.get()) == null) {
// identifiable = new Identifier(name);
// identifiableMap.put(name, new WeakReference<>(identifiable));
// }
// return identifiable;
// }
//
// }
//
// Path: src/main/java/nl/tudelft/ewi/gitolite/util/RecursiveAndPrototypeStreamingGroup.java
// public interface RecursiveAndPrototypeStreamingGroup<R extends RecursiveStreamingGroup<R, T>, T>
// extends RecursiveStreamingGroup<R, T>, PrototypeStreamingGroup<T> {
//
// @Override
// default Stream<T> getMembersStream() {
// return Stream.concat(Stream.concat(getPrototypeInheritedStream(), getRecursiveInheritedStream()), getOwnMembersStream());
// }
//
// }
| import com.google.common.base.Joiner;
import com.google.common.base.Preconditions;
import com.google.common.collect.Lists;
import lombok.Builder;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.Singular;
import lombok.SneakyThrows;
import nl.tudelft.ewi.gitolite.objects.Identifiable;
import nl.tudelft.ewi.gitolite.objects.Identifier;
import nl.tudelft.ewi.gitolite.util.RecursiveAndPrototypeStreamingGroup;
import java.io.IOException;
import java.io.StringWriter;
import java.io.Writer;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
import java.util.function.Predicate;
import java.util.stream.Stream; | package nl.tudelft.ewi.gitolite.parser.rules;
/**
* @author Jan-Willem Gmelig Meyling
*/
@Data
@Builder
//@EqualsAndHashCode(doNotUseGetters = true) | // Path: src/main/java/nl/tudelft/ewi/gitolite/objects/Identifiable.java
// public interface Identifiable extends Comparable<Identifiable>, Serializable {
//
// String getPattern();
//
// @Override
// default int compareTo(Identifiable o) {
// return getPattern().compareTo(o.getPattern());
// }
//
// }
//
// Path: src/main/java/nl/tudelft/ewi/gitolite/objects/Identifier.java
// @Value
// public class Identifier implements Identifiable {
//
// /**
// * The name for the identifier
// */
// private final String pattern;
//
// private final static WeakHashMap<String, WeakReference<Identifier>> identifiableMap = new WeakHashMap<>();
//
// /**
// * Get an identifier. As {@code Identifiers} should be immutable, they are stored in a
// * {@code WeakHashMap} for caching purposes. This method tries to find {@code Identifiers}
// * in the cache first, and only creates a new instance if not. Therefore, this method is
// * preferred over using a constructor.
// *
// * @param name Name for the identifier.
// * @return Identifier
// */
// public static Identifier valueOf(String name) {
// WeakReference<Identifier> ref = identifiableMap.get(name);
// Identifier identifiable;
// if(ref == null || (identifiable = ref.get()) == null) {
// identifiable = new Identifier(name);
// identifiableMap.put(name, new WeakReference<>(identifiable));
// }
// return identifiable;
// }
//
// }
//
// Path: src/main/java/nl/tudelft/ewi/gitolite/util/RecursiveAndPrototypeStreamingGroup.java
// public interface RecursiveAndPrototypeStreamingGroup<R extends RecursiveStreamingGroup<R, T>, T>
// extends RecursiveStreamingGroup<R, T>, PrototypeStreamingGroup<T> {
//
// @Override
// default Stream<T> getMembersStream() {
// return Stream.concat(Stream.concat(getPrototypeInheritedStream(), getRecursiveInheritedStream()), getOwnMembersStream());
// }
//
// }
// Path: src/main/java/nl/tudelft/ewi/gitolite/parser/rules/GroupRule.java
import com.google.common.base.Joiner;
import com.google.common.base.Preconditions;
import com.google.common.collect.Lists;
import lombok.Builder;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.Singular;
import lombok.SneakyThrows;
import nl.tudelft.ewi.gitolite.objects.Identifiable;
import nl.tudelft.ewi.gitolite.objects.Identifier;
import nl.tudelft.ewi.gitolite.util.RecursiveAndPrototypeStreamingGroup;
import java.io.IOException;
import java.io.StringWriter;
import java.io.Writer;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
import java.util.function.Predicate;
import java.util.stream.Stream;
package nl.tudelft.ewi.gitolite.parser.rules;
/**
* @author Jan-Willem Gmelig Meyling
*/
@Data
@Builder
//@EqualsAndHashCode(doNotUseGetters = true) | public class GroupRule implements RecursiveAndPrototypeStreamingGroup<GroupRule, Identifier>, Rule, Identifiable { |
devhub-tud/Java-Gitolite-Manager | src/main/java/nl/tudelft/ewi/gitolite/parser/rules/GroupRule.java | // Path: src/main/java/nl/tudelft/ewi/gitolite/objects/Identifiable.java
// public interface Identifiable extends Comparable<Identifiable>, Serializable {
//
// String getPattern();
//
// @Override
// default int compareTo(Identifiable o) {
// return getPattern().compareTo(o.getPattern());
// }
//
// }
//
// Path: src/main/java/nl/tudelft/ewi/gitolite/objects/Identifier.java
// @Value
// public class Identifier implements Identifiable {
//
// /**
// * The name for the identifier
// */
// private final String pattern;
//
// private final static WeakHashMap<String, WeakReference<Identifier>> identifiableMap = new WeakHashMap<>();
//
// /**
// * Get an identifier. As {@code Identifiers} should be immutable, they are stored in a
// * {@code WeakHashMap} for caching purposes. This method tries to find {@code Identifiers}
// * in the cache first, and only creates a new instance if not. Therefore, this method is
// * preferred over using a constructor.
// *
// * @param name Name for the identifier.
// * @return Identifier
// */
// public static Identifier valueOf(String name) {
// WeakReference<Identifier> ref = identifiableMap.get(name);
// Identifier identifiable;
// if(ref == null || (identifiable = ref.get()) == null) {
// identifiable = new Identifier(name);
// identifiableMap.put(name, new WeakReference<>(identifiable));
// }
// return identifiable;
// }
//
// }
//
// Path: src/main/java/nl/tudelft/ewi/gitolite/util/RecursiveAndPrototypeStreamingGroup.java
// public interface RecursiveAndPrototypeStreamingGroup<R extends RecursiveStreamingGroup<R, T>, T>
// extends RecursiveStreamingGroup<R, T>, PrototypeStreamingGroup<T> {
//
// @Override
// default Stream<T> getMembersStream() {
// return Stream.concat(Stream.concat(getPrototypeInheritedStream(), getRecursiveInheritedStream()), getOwnMembersStream());
// }
//
// }
| import com.google.common.base.Joiner;
import com.google.common.base.Preconditions;
import com.google.common.collect.Lists;
import lombok.Builder;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.Singular;
import lombok.SneakyThrows;
import nl.tudelft.ewi.gitolite.objects.Identifiable;
import nl.tudelft.ewi.gitolite.objects.Identifier;
import nl.tudelft.ewi.gitolite.util.RecursiveAndPrototypeStreamingGroup;
import java.io.IOException;
import java.io.StringWriter;
import java.io.Writer;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
import java.util.function.Predicate;
import java.util.stream.Stream; | package nl.tudelft.ewi.gitolite.parser.rules;
/**
* @author Jan-Willem Gmelig Meyling
*/
@Data
@Builder
//@EqualsAndHashCode(doNotUseGetters = true) | // Path: src/main/java/nl/tudelft/ewi/gitolite/objects/Identifiable.java
// public interface Identifiable extends Comparable<Identifiable>, Serializable {
//
// String getPattern();
//
// @Override
// default int compareTo(Identifiable o) {
// return getPattern().compareTo(o.getPattern());
// }
//
// }
//
// Path: src/main/java/nl/tudelft/ewi/gitolite/objects/Identifier.java
// @Value
// public class Identifier implements Identifiable {
//
// /**
// * The name for the identifier
// */
// private final String pattern;
//
// private final static WeakHashMap<String, WeakReference<Identifier>> identifiableMap = new WeakHashMap<>();
//
// /**
// * Get an identifier. As {@code Identifiers} should be immutable, they are stored in a
// * {@code WeakHashMap} for caching purposes. This method tries to find {@code Identifiers}
// * in the cache first, and only creates a new instance if not. Therefore, this method is
// * preferred over using a constructor.
// *
// * @param name Name for the identifier.
// * @return Identifier
// */
// public static Identifier valueOf(String name) {
// WeakReference<Identifier> ref = identifiableMap.get(name);
// Identifier identifiable;
// if(ref == null || (identifiable = ref.get()) == null) {
// identifiable = new Identifier(name);
// identifiableMap.put(name, new WeakReference<>(identifiable));
// }
// return identifiable;
// }
//
// }
//
// Path: src/main/java/nl/tudelft/ewi/gitolite/util/RecursiveAndPrototypeStreamingGroup.java
// public interface RecursiveAndPrototypeStreamingGroup<R extends RecursiveStreamingGroup<R, T>, T>
// extends RecursiveStreamingGroup<R, T>, PrototypeStreamingGroup<T> {
//
// @Override
// default Stream<T> getMembersStream() {
// return Stream.concat(Stream.concat(getPrototypeInheritedStream(), getRecursiveInheritedStream()), getOwnMembersStream());
// }
//
// }
// Path: src/main/java/nl/tudelft/ewi/gitolite/parser/rules/GroupRule.java
import com.google.common.base.Joiner;
import com.google.common.base.Preconditions;
import com.google.common.collect.Lists;
import lombok.Builder;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.Singular;
import lombok.SneakyThrows;
import nl.tudelft.ewi.gitolite.objects.Identifiable;
import nl.tudelft.ewi.gitolite.objects.Identifier;
import nl.tudelft.ewi.gitolite.util.RecursiveAndPrototypeStreamingGroup;
import java.io.IOException;
import java.io.StringWriter;
import java.io.Writer;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
import java.util.function.Predicate;
import java.util.stream.Stream;
package nl.tudelft.ewi.gitolite.parser.rules;
/**
* @author Jan-Willem Gmelig Meyling
*/
@Data
@Builder
//@EqualsAndHashCode(doNotUseGetters = true) | public class GroupRule implements RecursiveAndPrototypeStreamingGroup<GroupRule, Identifier>, Rule, Identifiable { |
devhub-tud/Java-Gitolite-Manager | src/main/java/nl/tudelft/ewi/gitolite/parser/rules/GroupRule.java | // Path: src/main/java/nl/tudelft/ewi/gitolite/objects/Identifiable.java
// public interface Identifiable extends Comparable<Identifiable>, Serializable {
//
// String getPattern();
//
// @Override
// default int compareTo(Identifiable o) {
// return getPattern().compareTo(o.getPattern());
// }
//
// }
//
// Path: src/main/java/nl/tudelft/ewi/gitolite/objects/Identifier.java
// @Value
// public class Identifier implements Identifiable {
//
// /**
// * The name for the identifier
// */
// private final String pattern;
//
// private final static WeakHashMap<String, WeakReference<Identifier>> identifiableMap = new WeakHashMap<>();
//
// /**
// * Get an identifier. As {@code Identifiers} should be immutable, they are stored in a
// * {@code WeakHashMap} for caching purposes. This method tries to find {@code Identifiers}
// * in the cache first, and only creates a new instance if not. Therefore, this method is
// * preferred over using a constructor.
// *
// * @param name Name for the identifier.
// * @return Identifier
// */
// public static Identifier valueOf(String name) {
// WeakReference<Identifier> ref = identifiableMap.get(name);
// Identifier identifiable;
// if(ref == null || (identifiable = ref.get()) == null) {
// identifiable = new Identifier(name);
// identifiableMap.put(name, new WeakReference<>(identifiable));
// }
// return identifiable;
// }
//
// }
//
// Path: src/main/java/nl/tudelft/ewi/gitolite/util/RecursiveAndPrototypeStreamingGroup.java
// public interface RecursiveAndPrototypeStreamingGroup<R extends RecursiveStreamingGroup<R, T>, T>
// extends RecursiveStreamingGroup<R, T>, PrototypeStreamingGroup<T> {
//
// @Override
// default Stream<T> getMembersStream() {
// return Stream.concat(Stream.concat(getPrototypeInheritedStream(), getRecursiveInheritedStream()), getOwnMembersStream());
// }
//
// }
| import com.google.common.base.Joiner;
import com.google.common.base.Preconditions;
import com.google.common.collect.Lists;
import lombok.Builder;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.Singular;
import lombok.SneakyThrows;
import nl.tudelft.ewi.gitolite.objects.Identifiable;
import nl.tudelft.ewi.gitolite.objects.Identifier;
import nl.tudelft.ewi.gitolite.util.RecursiveAndPrototypeStreamingGroup;
import java.io.IOException;
import java.io.StringWriter;
import java.io.Writer;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
import java.util.function.Predicate;
import java.util.stream.Stream; | package nl.tudelft.ewi.gitolite.parser.rules;
/**
* @author Jan-Willem Gmelig Meyling
*/
@Data
@Builder
//@EqualsAndHashCode(doNotUseGetters = true) | // Path: src/main/java/nl/tudelft/ewi/gitolite/objects/Identifiable.java
// public interface Identifiable extends Comparable<Identifiable>, Serializable {
//
// String getPattern();
//
// @Override
// default int compareTo(Identifiable o) {
// return getPattern().compareTo(o.getPattern());
// }
//
// }
//
// Path: src/main/java/nl/tudelft/ewi/gitolite/objects/Identifier.java
// @Value
// public class Identifier implements Identifiable {
//
// /**
// * The name for the identifier
// */
// private final String pattern;
//
// private final static WeakHashMap<String, WeakReference<Identifier>> identifiableMap = new WeakHashMap<>();
//
// /**
// * Get an identifier. As {@code Identifiers} should be immutable, they are stored in a
// * {@code WeakHashMap} for caching purposes. This method tries to find {@code Identifiers}
// * in the cache first, and only creates a new instance if not. Therefore, this method is
// * preferred over using a constructor.
// *
// * @param name Name for the identifier.
// * @return Identifier
// */
// public static Identifier valueOf(String name) {
// WeakReference<Identifier> ref = identifiableMap.get(name);
// Identifier identifiable;
// if(ref == null || (identifiable = ref.get()) == null) {
// identifiable = new Identifier(name);
// identifiableMap.put(name, new WeakReference<>(identifiable));
// }
// return identifiable;
// }
//
// }
//
// Path: src/main/java/nl/tudelft/ewi/gitolite/util/RecursiveAndPrototypeStreamingGroup.java
// public interface RecursiveAndPrototypeStreamingGroup<R extends RecursiveStreamingGroup<R, T>, T>
// extends RecursiveStreamingGroup<R, T>, PrototypeStreamingGroup<T> {
//
// @Override
// default Stream<T> getMembersStream() {
// return Stream.concat(Stream.concat(getPrototypeInheritedStream(), getRecursiveInheritedStream()), getOwnMembersStream());
// }
//
// }
// Path: src/main/java/nl/tudelft/ewi/gitolite/parser/rules/GroupRule.java
import com.google.common.base.Joiner;
import com.google.common.base.Preconditions;
import com.google.common.collect.Lists;
import lombok.Builder;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.Singular;
import lombok.SneakyThrows;
import nl.tudelft.ewi.gitolite.objects.Identifiable;
import nl.tudelft.ewi.gitolite.objects.Identifier;
import nl.tudelft.ewi.gitolite.util.RecursiveAndPrototypeStreamingGroup;
import java.io.IOException;
import java.io.StringWriter;
import java.io.Writer;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
import java.util.function.Predicate;
import java.util.stream.Stream;
package nl.tudelft.ewi.gitolite.parser.rules;
/**
* @author Jan-Willem Gmelig Meyling
*/
@Data
@Builder
//@EqualsAndHashCode(doNotUseGetters = true) | public class GroupRule implements RecursiveAndPrototypeStreamingGroup<GroupRule, Identifier>, Rule, Identifiable { |
devhub-tud/Java-Gitolite-Manager | src/main/java/nl/tudelft/ewi/gitolite/parser/rules/AccessRule.java | // Path: src/main/java/nl/tudelft/ewi/gitolite/objects/Identifiable.java
// public interface Identifiable extends Comparable<Identifiable>, Serializable {
//
// String getPattern();
//
// @Override
// default int compareTo(Identifiable o) {
// return getPattern().compareTo(o.getPattern());
// }
//
// }
//
// Path: src/main/java/nl/tudelft/ewi/gitolite/objects/Identifier.java
// @Value
// public class Identifier implements Identifiable {
//
// /**
// * The name for the identifier
// */
// private final String pattern;
//
// private final static WeakHashMap<String, WeakReference<Identifier>> identifiableMap = new WeakHashMap<>();
//
// /**
// * Get an identifier. As {@code Identifiers} should be immutable, they are stored in a
// * {@code WeakHashMap} for caching purposes. This method tries to find {@code Identifiers}
// * in the cache first, and only creates a new instance if not. Therefore, this method is
// * preferred over using a constructor.
// *
// * @param name Name for the identifier.
// * @return Identifier
// */
// public static Identifier valueOf(String name) {
// WeakReference<Identifier> ref = identifiableMap.get(name);
// Identifier identifiable;
// if(ref == null || (identifiable = ref.get()) == null) {
// identifiable = new Identifier(name);
// identifiableMap.put(name, new WeakReference<>(identifiable));
// }
// return identifiable;
// }
//
// }
//
// Path: src/main/java/nl/tudelft/ewi/gitolite/permission/Permission.java
// public interface Permission {
//
// /**
// * @return the {@link BasePermission} for this {@link Permission}.
// */
// BasePermission getBasePermission();
//
// /**
// * @return the {@link PermissionModifier PermissionModifiers} for this {@link Permission}.
// * If the current {@code Permission} is a {@link BasePermission}, then it returns an empty list.
// */
// Collection<PermissionModifier> getModifiers();
//
// /**
// * Regular expression that matches permissions
// */
// Pattern PERMISSION_PATTERN = Pattern.compile("^(-|C|R|RW\\+?)((?:C?D?|D?C?)M?)$");
//
// /**
// * @return String value of this permission.
// */
// String valueOf();
//
// /**
// * Parse a {@code Permission}.
// * @param input String to parse
// * @return the parsed permission.
// */
// static Permission valueOf(String input) {
// Matcher matcher = PERMISSION_PATTERN.matcher(input);
// if(!matcher.matches()) {
// throw new IllegalArgumentException(String.format("Input %s should be in the format %s",
// input, PERMISSION_PATTERN.pattern()));
// }
// BasePermission basePermission = BasePermission.parse(matcher.group(1));
// SortedSet<PermissionModifier> modifiers = PermissionModifier.parse(matcher.group(2));
// if(modifiers.isEmpty()) {
// return basePermission;
// }
// return new PermissionWithModifier(basePermission, modifiers);
// }
//
// }
| import com.google.common.base.Preconditions;
import com.google.common.base.Strings;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.SneakyThrows;
import nl.tudelft.ewi.gitolite.objects.Identifiable;
import nl.tudelft.ewi.gitolite.objects.Identifier;
import nl.tudelft.ewi.gitolite.permission.Permission;
import java.io.IOException;
import java.io.StringWriter;
import java.io.Writer;
import java.util.Collection; | package nl.tudelft.ewi.gitolite.parser.rules;
/**
* @author Jan-Willem Gmelig Meyling
*/
@EqualsAndHashCode
public class AccessRule implements Writable {
private final static String REFS_HEADS = "refs/heads/";
/**
* If no refex is supplied, it defaults to refs/.*, for example in a rule like this:
*
* {@code <pre>
* RW = alice
* </pre>}
*/
public final static String DEFAULT_REFEX = "refs/.*";
/**
* A pattern for usernames.
*/
public final static String USER_PATTERN = "^\\w[\\w._\\@+-]+$";
/**
* The permission field gives the type of access this rule line permits.
*/
@Getter | // Path: src/main/java/nl/tudelft/ewi/gitolite/objects/Identifiable.java
// public interface Identifiable extends Comparable<Identifiable>, Serializable {
//
// String getPattern();
//
// @Override
// default int compareTo(Identifiable o) {
// return getPattern().compareTo(o.getPattern());
// }
//
// }
//
// Path: src/main/java/nl/tudelft/ewi/gitolite/objects/Identifier.java
// @Value
// public class Identifier implements Identifiable {
//
// /**
// * The name for the identifier
// */
// private final String pattern;
//
// private final static WeakHashMap<String, WeakReference<Identifier>> identifiableMap = new WeakHashMap<>();
//
// /**
// * Get an identifier. As {@code Identifiers} should be immutable, they are stored in a
// * {@code WeakHashMap} for caching purposes. This method tries to find {@code Identifiers}
// * in the cache first, and only creates a new instance if not. Therefore, this method is
// * preferred over using a constructor.
// *
// * @param name Name for the identifier.
// * @return Identifier
// */
// public static Identifier valueOf(String name) {
// WeakReference<Identifier> ref = identifiableMap.get(name);
// Identifier identifiable;
// if(ref == null || (identifiable = ref.get()) == null) {
// identifiable = new Identifier(name);
// identifiableMap.put(name, new WeakReference<>(identifiable));
// }
// return identifiable;
// }
//
// }
//
// Path: src/main/java/nl/tudelft/ewi/gitolite/permission/Permission.java
// public interface Permission {
//
// /**
// * @return the {@link BasePermission} for this {@link Permission}.
// */
// BasePermission getBasePermission();
//
// /**
// * @return the {@link PermissionModifier PermissionModifiers} for this {@link Permission}.
// * If the current {@code Permission} is a {@link BasePermission}, then it returns an empty list.
// */
// Collection<PermissionModifier> getModifiers();
//
// /**
// * Regular expression that matches permissions
// */
// Pattern PERMISSION_PATTERN = Pattern.compile("^(-|C|R|RW\\+?)((?:C?D?|D?C?)M?)$");
//
// /**
// * @return String value of this permission.
// */
// String valueOf();
//
// /**
// * Parse a {@code Permission}.
// * @param input String to parse
// * @return the parsed permission.
// */
// static Permission valueOf(String input) {
// Matcher matcher = PERMISSION_PATTERN.matcher(input);
// if(!matcher.matches()) {
// throw new IllegalArgumentException(String.format("Input %s should be in the format %s",
// input, PERMISSION_PATTERN.pattern()));
// }
// BasePermission basePermission = BasePermission.parse(matcher.group(1));
// SortedSet<PermissionModifier> modifiers = PermissionModifier.parse(matcher.group(2));
// if(modifiers.isEmpty()) {
// return basePermission;
// }
// return new PermissionWithModifier(basePermission, modifiers);
// }
//
// }
// Path: src/main/java/nl/tudelft/ewi/gitolite/parser/rules/AccessRule.java
import com.google.common.base.Preconditions;
import com.google.common.base.Strings;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.SneakyThrows;
import nl.tudelft.ewi.gitolite.objects.Identifiable;
import nl.tudelft.ewi.gitolite.objects.Identifier;
import nl.tudelft.ewi.gitolite.permission.Permission;
import java.io.IOException;
import java.io.StringWriter;
import java.io.Writer;
import java.util.Collection;
package nl.tudelft.ewi.gitolite.parser.rules;
/**
* @author Jan-Willem Gmelig Meyling
*/
@EqualsAndHashCode
public class AccessRule implements Writable {
private final static String REFS_HEADS = "refs/heads/";
/**
* If no refex is supplied, it defaults to refs/.*, for example in a rule like this:
*
* {@code <pre>
* RW = alice
* </pre>}
*/
public final static String DEFAULT_REFEX = "refs/.*";
/**
* A pattern for usernames.
*/
public final static String USER_PATTERN = "^\\w[\\w._\\@+-]+$";
/**
* The permission field gives the type of access this rule line permits.
*/
@Getter | private final Permission permission; |
devhub-tud/Java-Gitolite-Manager | src/main/java/nl/tudelft/ewi/gitolite/parser/rules/AccessRule.java | // Path: src/main/java/nl/tudelft/ewi/gitolite/objects/Identifiable.java
// public interface Identifiable extends Comparable<Identifiable>, Serializable {
//
// String getPattern();
//
// @Override
// default int compareTo(Identifiable o) {
// return getPattern().compareTo(o.getPattern());
// }
//
// }
//
// Path: src/main/java/nl/tudelft/ewi/gitolite/objects/Identifier.java
// @Value
// public class Identifier implements Identifiable {
//
// /**
// * The name for the identifier
// */
// private final String pattern;
//
// private final static WeakHashMap<String, WeakReference<Identifier>> identifiableMap = new WeakHashMap<>();
//
// /**
// * Get an identifier. As {@code Identifiers} should be immutable, they are stored in a
// * {@code WeakHashMap} for caching purposes. This method tries to find {@code Identifiers}
// * in the cache first, and only creates a new instance if not. Therefore, this method is
// * preferred over using a constructor.
// *
// * @param name Name for the identifier.
// * @return Identifier
// */
// public static Identifier valueOf(String name) {
// WeakReference<Identifier> ref = identifiableMap.get(name);
// Identifier identifiable;
// if(ref == null || (identifiable = ref.get()) == null) {
// identifiable = new Identifier(name);
// identifiableMap.put(name, new WeakReference<>(identifiable));
// }
// return identifiable;
// }
//
// }
//
// Path: src/main/java/nl/tudelft/ewi/gitolite/permission/Permission.java
// public interface Permission {
//
// /**
// * @return the {@link BasePermission} for this {@link Permission}.
// */
// BasePermission getBasePermission();
//
// /**
// * @return the {@link PermissionModifier PermissionModifiers} for this {@link Permission}.
// * If the current {@code Permission} is a {@link BasePermission}, then it returns an empty list.
// */
// Collection<PermissionModifier> getModifiers();
//
// /**
// * Regular expression that matches permissions
// */
// Pattern PERMISSION_PATTERN = Pattern.compile("^(-|C|R|RW\\+?)((?:C?D?|D?C?)M?)$");
//
// /**
// * @return String value of this permission.
// */
// String valueOf();
//
// /**
// * Parse a {@code Permission}.
// * @param input String to parse
// * @return the parsed permission.
// */
// static Permission valueOf(String input) {
// Matcher matcher = PERMISSION_PATTERN.matcher(input);
// if(!matcher.matches()) {
// throw new IllegalArgumentException(String.format("Input %s should be in the format %s",
// input, PERMISSION_PATTERN.pattern()));
// }
// BasePermission basePermission = BasePermission.parse(matcher.group(1));
// SortedSet<PermissionModifier> modifiers = PermissionModifier.parse(matcher.group(2));
// if(modifiers.isEmpty()) {
// return basePermission;
// }
// return new PermissionWithModifier(basePermission, modifiers);
// }
//
// }
| import com.google.common.base.Preconditions;
import com.google.common.base.Strings;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.SneakyThrows;
import nl.tudelft.ewi.gitolite.objects.Identifiable;
import nl.tudelft.ewi.gitolite.objects.Identifier;
import nl.tudelft.ewi.gitolite.permission.Permission;
import java.io.IOException;
import java.io.StringWriter;
import java.io.Writer;
import java.util.Collection; | package nl.tudelft.ewi.gitolite.parser.rules;
/**
* @author Jan-Willem Gmelig Meyling
*/
@EqualsAndHashCode
public class AccessRule implements Writable {
private final static String REFS_HEADS = "refs/heads/";
/**
* If no refex is supplied, it defaults to refs/.*, for example in a rule like this:
*
* {@code <pre>
* RW = alice
* </pre>}
*/
public final static String DEFAULT_REFEX = "refs/.*";
/**
* A pattern for usernames.
*/
public final static String USER_PATTERN = "^\\w[\\w._\\@+-]+$";
/**
* The permission field gives the type of access this rule line permits.
*/
@Getter
private final Permission permission;
/**
* A refex is a word I made up to mean "a regex that matches a ref".
*
* <ul>
* <li>
* If no refex is supplied, it defaults to {@code refs/.*}.
* A refex not starting with {@code refs/} (or {@code VREF/}) is assumed to start with {@code refs/heads/}.
* </li>
* <li>
* A refex is implicitly anchored at the start, but not at the end.
* </li>
* <li>
* In regular expression lingo, a {@code ^} is assumed at the start
* (but no {@code $} at the end is assumed).
* </li>
* </ul>
*/
@Getter
private final String refex;
/**
* Like the repos on the repo line, you can have any number of user names and/or user group names on the rule line.
* (However, please note that there is no concept of regular expressions for user names).
*/
@Getter
private final InlineUserGroup members;
/**
* Shorthand that allows you to write constructs like: {@code new RepositoryRule(Permission.RW_PLUS, foo)}.
* @param permission {@link Permission} for this {@code Rule}.
* @param identifiable {@link Identifiable Identifiables} for this {@code Rule}.
* @see AccessRule#AccessRule(Permission, String, InlineUserGroup)
*/ | // Path: src/main/java/nl/tudelft/ewi/gitolite/objects/Identifiable.java
// public interface Identifiable extends Comparable<Identifiable>, Serializable {
//
// String getPattern();
//
// @Override
// default int compareTo(Identifiable o) {
// return getPattern().compareTo(o.getPattern());
// }
//
// }
//
// Path: src/main/java/nl/tudelft/ewi/gitolite/objects/Identifier.java
// @Value
// public class Identifier implements Identifiable {
//
// /**
// * The name for the identifier
// */
// private final String pattern;
//
// private final static WeakHashMap<String, WeakReference<Identifier>> identifiableMap = new WeakHashMap<>();
//
// /**
// * Get an identifier. As {@code Identifiers} should be immutable, they are stored in a
// * {@code WeakHashMap} for caching purposes. This method tries to find {@code Identifiers}
// * in the cache first, and only creates a new instance if not. Therefore, this method is
// * preferred over using a constructor.
// *
// * @param name Name for the identifier.
// * @return Identifier
// */
// public static Identifier valueOf(String name) {
// WeakReference<Identifier> ref = identifiableMap.get(name);
// Identifier identifiable;
// if(ref == null || (identifiable = ref.get()) == null) {
// identifiable = new Identifier(name);
// identifiableMap.put(name, new WeakReference<>(identifiable));
// }
// return identifiable;
// }
//
// }
//
// Path: src/main/java/nl/tudelft/ewi/gitolite/permission/Permission.java
// public interface Permission {
//
// /**
// * @return the {@link BasePermission} for this {@link Permission}.
// */
// BasePermission getBasePermission();
//
// /**
// * @return the {@link PermissionModifier PermissionModifiers} for this {@link Permission}.
// * If the current {@code Permission} is a {@link BasePermission}, then it returns an empty list.
// */
// Collection<PermissionModifier> getModifiers();
//
// /**
// * Regular expression that matches permissions
// */
// Pattern PERMISSION_PATTERN = Pattern.compile("^(-|C|R|RW\\+?)((?:C?D?|D?C?)M?)$");
//
// /**
// * @return String value of this permission.
// */
// String valueOf();
//
// /**
// * Parse a {@code Permission}.
// * @param input String to parse
// * @return the parsed permission.
// */
// static Permission valueOf(String input) {
// Matcher matcher = PERMISSION_PATTERN.matcher(input);
// if(!matcher.matches()) {
// throw new IllegalArgumentException(String.format("Input %s should be in the format %s",
// input, PERMISSION_PATTERN.pattern()));
// }
// BasePermission basePermission = BasePermission.parse(matcher.group(1));
// SortedSet<PermissionModifier> modifiers = PermissionModifier.parse(matcher.group(2));
// if(modifiers.isEmpty()) {
// return basePermission;
// }
// return new PermissionWithModifier(basePermission, modifiers);
// }
//
// }
// Path: src/main/java/nl/tudelft/ewi/gitolite/parser/rules/AccessRule.java
import com.google.common.base.Preconditions;
import com.google.common.base.Strings;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.SneakyThrows;
import nl.tudelft.ewi.gitolite.objects.Identifiable;
import nl.tudelft.ewi.gitolite.objects.Identifier;
import nl.tudelft.ewi.gitolite.permission.Permission;
import java.io.IOException;
import java.io.StringWriter;
import java.io.Writer;
import java.util.Collection;
package nl.tudelft.ewi.gitolite.parser.rules;
/**
* @author Jan-Willem Gmelig Meyling
*/
@EqualsAndHashCode
public class AccessRule implements Writable {
private final static String REFS_HEADS = "refs/heads/";
/**
* If no refex is supplied, it defaults to refs/.*, for example in a rule like this:
*
* {@code <pre>
* RW = alice
* </pre>}
*/
public final static String DEFAULT_REFEX = "refs/.*";
/**
* A pattern for usernames.
*/
public final static String USER_PATTERN = "^\\w[\\w._\\@+-]+$";
/**
* The permission field gives the type of access this rule line permits.
*/
@Getter
private final Permission permission;
/**
* A refex is a word I made up to mean "a regex that matches a ref".
*
* <ul>
* <li>
* If no refex is supplied, it defaults to {@code refs/.*}.
* A refex not starting with {@code refs/} (or {@code VREF/}) is assumed to start with {@code refs/heads/}.
* </li>
* <li>
* A refex is implicitly anchored at the start, but not at the end.
* </li>
* <li>
* In regular expression lingo, a {@code ^} is assumed at the start
* (but no {@code $} at the end is assumed).
* </li>
* </ul>
*/
@Getter
private final String refex;
/**
* Like the repos on the repo line, you can have any number of user names and/or user group names on the rule line.
* (However, please note that there is no concept of regular expressions for user names).
*/
@Getter
private final InlineUserGroup members;
/**
* Shorthand that allows you to write constructs like: {@code new RepositoryRule(Permission.RW_PLUS, foo)}.
* @param permission {@link Permission} for this {@code Rule}.
* @param identifiable {@link Identifiable Identifiables} for this {@code Rule}.
* @see AccessRule#AccessRule(Permission, String, InlineUserGroup)
*/ | public AccessRule(final Permission permission, final Identifier... identifiable) { |
Terasology/Cities | src/main/java/org/terasology/cities/bldg/gen/Turtle.java | // Path: src/main/java/org/terasology/cities/common/Edges.java
// public final class Edges {
//
// private Edges() {
// // no instances
// }
//
// public static Vector2i getCorner(BlockAreac rc, Orientation o) {
//
// int dx = o.direction().x() + 1; // [0..2]
// int dy = o.direction().y() + 1; // [0..2]
//
// int x = rc.minX() + (rc.getSizeX() - 1) * dx / 2;
// int y = rc.minY() + (rc.getSizeY() - 1) * dy / 2;
//
// return new Vector2i(x, y);
// }
//
// public static int getDistanceToBorder(BlockAreac rc, int x, int z) {
// int rx = x - rc.minX();
// int rz = z - rc.minY();
//
// // distance to border along both axes
// int borderDistX = Math.min(rx, rc.getSizeX() - 1 - rx);
// int borderDistZ = Math.min(rz, rc.getSizeY() - 1 - rz);
//
// int dist = Math.min(borderDistX, borderDistZ);
// return dist;
// }
//
// public static float getDistanceToCorner(BlockAreac rc, int x, int y) {
// return (float) Math.sqrt(getDistanceToCorner(rc, x, y));
// }
//
// public static int getDistanceToCornerSq(BlockAreac rc, int x, int y) {
// int dx = Math.min(x - rc.minX(), rc.maxX() - x);
// int dy = Math.min(y - rc.minY(), rc.maxY() - y);
// return dx * dx + dy * dy;
// }
//
// public static Line2f getEdge(BlockAreac rc, Orientation o) {
//
// Vector2i p0 = getCorner(rc, o.getRotated(-45));
// Vector2i p1 = getCorner(rc, o.getRotated(45));
// return new Line2f(p0.x(), p0.y(), p1.x(), p1.y());
// }
// }
| import org.joml.Vector2i;
import org.joml.Vector2ic;
import org.terasology.cities.common.Edges;
import org.terasology.commonworld.Orientation;
import org.terasology.engine.world.block.BlockArea;
import org.terasology.engine.world.block.BlockAreac; | int maxY = pos.y() + rotateY(dir, right + width - 1, forward + len - 1);
return new BlockArea(minX, minY).union(maxX, maxY);
}
/**
* Creates a rectangle that is centered along the current direction.
* <pre>
* x------x
* o-> | |
* x------x
* </pre>
* @param forward the offset along the direction axis
* @param width the width of the rectangle
* @param len the length of the rectangle
* @return the rectangle
*/
public BlockAreac rectCentered(int forward, int width, int len) {
return rect(-width / 2, forward, width, len);
}
/**
* @param rc the rectangle to adjust
* @param left the offset of the left edge
* @param back the offset of the back edge
* @param right the offset of the right edge
* @param forward the offset of the forward edge
* @return a new rect with adjusted coordinates
*/
public BlockAreac adjustRect(BlockAreac rc, int left, int back, int right, int forward) {
Orientation cd = orient.getRotated(45); | // Path: src/main/java/org/terasology/cities/common/Edges.java
// public final class Edges {
//
// private Edges() {
// // no instances
// }
//
// public static Vector2i getCorner(BlockAreac rc, Orientation o) {
//
// int dx = o.direction().x() + 1; // [0..2]
// int dy = o.direction().y() + 1; // [0..2]
//
// int x = rc.minX() + (rc.getSizeX() - 1) * dx / 2;
// int y = rc.minY() + (rc.getSizeY() - 1) * dy / 2;
//
// return new Vector2i(x, y);
// }
//
// public static int getDistanceToBorder(BlockAreac rc, int x, int z) {
// int rx = x - rc.minX();
// int rz = z - rc.minY();
//
// // distance to border along both axes
// int borderDistX = Math.min(rx, rc.getSizeX() - 1 - rx);
// int borderDistZ = Math.min(rz, rc.getSizeY() - 1 - rz);
//
// int dist = Math.min(borderDistX, borderDistZ);
// return dist;
// }
//
// public static float getDistanceToCorner(BlockAreac rc, int x, int y) {
// return (float) Math.sqrt(getDistanceToCorner(rc, x, y));
// }
//
// public static int getDistanceToCornerSq(BlockAreac rc, int x, int y) {
// int dx = Math.min(x - rc.minX(), rc.maxX() - x);
// int dy = Math.min(y - rc.minY(), rc.maxY() - y);
// return dx * dx + dy * dy;
// }
//
// public static Line2f getEdge(BlockAreac rc, Orientation o) {
//
// Vector2i p0 = getCorner(rc, o.getRotated(-45));
// Vector2i p1 = getCorner(rc, o.getRotated(45));
// return new Line2f(p0.x(), p0.y(), p1.x(), p1.y());
// }
// }
// Path: src/main/java/org/terasology/cities/bldg/gen/Turtle.java
import org.joml.Vector2i;
import org.joml.Vector2ic;
import org.terasology.cities.common.Edges;
import org.terasology.commonworld.Orientation;
import org.terasology.engine.world.block.BlockArea;
import org.terasology.engine.world.block.BlockAreac;
int maxY = pos.y() + rotateY(dir, right + width - 1, forward + len - 1);
return new BlockArea(minX, minY).union(maxX, maxY);
}
/**
* Creates a rectangle that is centered along the current direction.
* <pre>
* x------x
* o-> | |
* x------x
* </pre>
* @param forward the offset along the direction axis
* @param width the width of the rectangle
* @param len the length of the rectangle
* @return the rectangle
*/
public BlockAreac rectCentered(int forward, int width, int len) {
return rect(-width / 2, forward, width, len);
}
/**
* @param rc the rectangle to adjust
* @param left the offset of the left edge
* @param back the offset of the back edge
* @param right the offset of the right edge
* @param forward the offset of the forward edge
* @return a new rect with adjusted coordinates
*/
public BlockAreac adjustRect(BlockAreac rc, int left, int back, int right, int forward) {
Orientation cd = orient.getRotated(45); | Vector2i max = Edges.getCorner(rc, cd); |
Terasology/Cities | src/main/java/org/terasology/cities/bldg/SimpleTower.java | // Path: src/main/java/org/terasology/cities/common/Edges.java
// public final class Edges {
//
// private Edges() {
// // no instances
// }
//
// public static Vector2i getCorner(BlockAreac rc, Orientation o) {
//
// int dx = o.direction().x() + 1; // [0..2]
// int dy = o.direction().y() + 1; // [0..2]
//
// int x = rc.minX() + (rc.getSizeX() - 1) * dx / 2;
// int y = rc.minY() + (rc.getSizeY() - 1) * dy / 2;
//
// return new Vector2i(x, y);
// }
//
// public static int getDistanceToBorder(BlockAreac rc, int x, int z) {
// int rx = x - rc.minX();
// int rz = z - rc.minY();
//
// // distance to border along both axes
// int borderDistX = Math.min(rx, rc.getSizeX() - 1 - rx);
// int borderDistZ = Math.min(rz, rc.getSizeY() - 1 - rz);
//
// int dist = Math.min(borderDistX, borderDistZ);
// return dist;
// }
//
// public static float getDistanceToCorner(BlockAreac rc, int x, int y) {
// return (float) Math.sqrt(getDistanceToCorner(rc, x, y));
// }
//
// public static int getDistanceToCornerSq(BlockAreac rc, int x, int y) {
// int dx = Math.min(x - rc.minX(), rc.maxX() - x);
// int dy = Math.min(y - rc.minY(), rc.maxY() - y);
// return dx * dx + dy * dy;
// }
//
// public static Line2f getEdge(BlockAreac rc, Orientation o) {
//
// Vector2i p0 = getCorner(rc, o.getRotated(-45));
// Vector2i p1 = getCorner(rc, o.getRotated(45));
// return new Line2f(p0.x(), p0.y(), p1.x(), p1.y());
// }
// }
//
// Path: src/main/java/org/terasology/cities/door/SimpleDoor.java
// public class SimpleDoor implements Door {
//
// private final Orientation orientation;
// private final int baseHeight;
// private final int topHeight;
// private final Vector2i pos = new Vector2i();
//
// /**
// * @param orientation the orientation
// * @param pos the position in the XZ plane
// * @param baseHeight the height at the bottom
// * @param topHeight the height at the top
// */
// public SimpleDoor(Orientation orientation, Vector2ic pos, int baseHeight, int topHeight) {
// this.orientation = orientation;
// this.pos.set(pos);
// this.baseHeight = baseHeight;
// this.topHeight = topHeight;
// }
//
// /**
// * @return the orientation
// */
// public Orientation getOrientation() {
// return this.orientation;
// }
//
// /**
// * @return the door position
// */
// public Vector2ic getPos() {
// return this.pos;
// }
//
// /**
// * @return the baseHeight
// */
// public int getBaseHeight() {
// return this.baseHeight;
// }
//
// /**
// * @return the topHeight
// */
// public int getTopHeight() {
// return this.topHeight;
// }
// }
//
// Path: src/main/java/org/terasology/cities/model/roof/BattlementRoof.java
// public class BattlementRoof extends FlatRoof {
//
// /**
// * @param baseRect the building rectangle (must be fully inside <code>withEaves</code>).
// * @param withEaves the roof area including eaves (=overhang)
// * @param baseHeight the base height of the roof
// * @param merlonHeight the height of the border
// */
// public BattlementRoof(BlockAreac baseRect, BlockAreac withEaves, int baseHeight, int merlonHeight) {
// super(baseRect, withEaves, baseHeight, merlonHeight);
// }
//
// /**
// * @param lx x in local (roof area) coordinates
// * @param lz z in local (roof area) coordinates
// * @return the borderHeight
// */
// @Override
// public int getBorderHeight(int lx, int lz) {
// if (lx % 2 == 1) {
// return 0;
// }
//
// if (lz % 2 == 1) {
// return 0;
// }
//
// return super.getBorderHeight(lx, lz);
// }
// }
//
// Path: src/main/java/org/terasology/cities/model/roof/Roof.java
// public interface Roof {
//
//
// }
| import org.joml.Vector2i;
import org.terasology.cities.common.Edges;
import org.terasology.cities.door.SimpleDoor;
import org.terasology.cities.model.roof.BattlementRoof;
import org.terasology.cities.model.roof.Roof;
import org.terasology.commonworld.Orientation;
import org.terasology.engine.world.block.BlockArea;
import org.terasology.engine.world.block.BlockAreac; | /*
* Copyright 2015 MovingBlocks
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.terasology.cities.bldg;
/**
* A simple tower
*/
public class SimpleTower extends DefaultBuilding implements Tower {
private BlockArea shape = new BlockArea(BlockArea.INVALID);
private RectBuildingPart room;
/**
* @param orient the orientation of the building
* @param layout the building layout
* @param baseHeight the height of the floor level
* @param wallHeight the building height above the floor level
*/
public SimpleTower(Orientation orient, BlockAreac layout, int baseHeight, int wallHeight) {
super(orient);
this.shape.set(layout);
BlockArea roofArea = layout.expand(1, 1,new BlockArea(BlockArea.INVALID)); | // Path: src/main/java/org/terasology/cities/common/Edges.java
// public final class Edges {
//
// private Edges() {
// // no instances
// }
//
// public static Vector2i getCorner(BlockAreac rc, Orientation o) {
//
// int dx = o.direction().x() + 1; // [0..2]
// int dy = o.direction().y() + 1; // [0..2]
//
// int x = rc.minX() + (rc.getSizeX() - 1) * dx / 2;
// int y = rc.minY() + (rc.getSizeY() - 1) * dy / 2;
//
// return new Vector2i(x, y);
// }
//
// public static int getDistanceToBorder(BlockAreac rc, int x, int z) {
// int rx = x - rc.minX();
// int rz = z - rc.minY();
//
// // distance to border along both axes
// int borderDistX = Math.min(rx, rc.getSizeX() - 1 - rx);
// int borderDistZ = Math.min(rz, rc.getSizeY() - 1 - rz);
//
// int dist = Math.min(borderDistX, borderDistZ);
// return dist;
// }
//
// public static float getDistanceToCorner(BlockAreac rc, int x, int y) {
// return (float) Math.sqrt(getDistanceToCorner(rc, x, y));
// }
//
// public static int getDistanceToCornerSq(BlockAreac rc, int x, int y) {
// int dx = Math.min(x - rc.minX(), rc.maxX() - x);
// int dy = Math.min(y - rc.minY(), rc.maxY() - y);
// return dx * dx + dy * dy;
// }
//
// public static Line2f getEdge(BlockAreac rc, Orientation o) {
//
// Vector2i p0 = getCorner(rc, o.getRotated(-45));
// Vector2i p1 = getCorner(rc, o.getRotated(45));
// return new Line2f(p0.x(), p0.y(), p1.x(), p1.y());
// }
// }
//
// Path: src/main/java/org/terasology/cities/door/SimpleDoor.java
// public class SimpleDoor implements Door {
//
// private final Orientation orientation;
// private final int baseHeight;
// private final int topHeight;
// private final Vector2i pos = new Vector2i();
//
// /**
// * @param orientation the orientation
// * @param pos the position in the XZ plane
// * @param baseHeight the height at the bottom
// * @param topHeight the height at the top
// */
// public SimpleDoor(Orientation orientation, Vector2ic pos, int baseHeight, int topHeight) {
// this.orientation = orientation;
// this.pos.set(pos);
// this.baseHeight = baseHeight;
// this.topHeight = topHeight;
// }
//
// /**
// * @return the orientation
// */
// public Orientation getOrientation() {
// return this.orientation;
// }
//
// /**
// * @return the door position
// */
// public Vector2ic getPos() {
// return this.pos;
// }
//
// /**
// * @return the baseHeight
// */
// public int getBaseHeight() {
// return this.baseHeight;
// }
//
// /**
// * @return the topHeight
// */
// public int getTopHeight() {
// return this.topHeight;
// }
// }
//
// Path: src/main/java/org/terasology/cities/model/roof/BattlementRoof.java
// public class BattlementRoof extends FlatRoof {
//
// /**
// * @param baseRect the building rectangle (must be fully inside <code>withEaves</code>).
// * @param withEaves the roof area including eaves (=overhang)
// * @param baseHeight the base height of the roof
// * @param merlonHeight the height of the border
// */
// public BattlementRoof(BlockAreac baseRect, BlockAreac withEaves, int baseHeight, int merlonHeight) {
// super(baseRect, withEaves, baseHeight, merlonHeight);
// }
//
// /**
// * @param lx x in local (roof area) coordinates
// * @param lz z in local (roof area) coordinates
// * @return the borderHeight
// */
// @Override
// public int getBorderHeight(int lx, int lz) {
// if (lx % 2 == 1) {
// return 0;
// }
//
// if (lz % 2 == 1) {
// return 0;
// }
//
// return super.getBorderHeight(lx, lz);
// }
// }
//
// Path: src/main/java/org/terasology/cities/model/roof/Roof.java
// public interface Roof {
//
//
// }
// Path: src/main/java/org/terasology/cities/bldg/SimpleTower.java
import org.joml.Vector2i;
import org.terasology.cities.common.Edges;
import org.terasology.cities.door.SimpleDoor;
import org.terasology.cities.model.roof.BattlementRoof;
import org.terasology.cities.model.roof.Roof;
import org.terasology.commonworld.Orientation;
import org.terasology.engine.world.block.BlockArea;
import org.terasology.engine.world.block.BlockAreac;
/*
* Copyright 2015 MovingBlocks
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.terasology.cities.bldg;
/**
* A simple tower
*/
public class SimpleTower extends DefaultBuilding implements Tower {
private BlockArea shape = new BlockArea(BlockArea.INVALID);
private RectBuildingPart room;
/**
* @param orient the orientation of the building
* @param layout the building layout
* @param baseHeight the height of the floor level
* @param wallHeight the building height above the floor level
*/
public SimpleTower(Orientation orient, BlockAreac layout, int baseHeight, int wallHeight) {
super(orient);
this.shape.set(layout);
BlockArea roofArea = layout.expand(1, 1,new BlockArea(BlockArea.INVALID)); | Roof roof = new BattlementRoof(layout, roofArea, baseHeight + wallHeight, 1); |
Terasology/Cities | src/main/java/org/terasology/cities/bldg/SimpleTower.java | // Path: src/main/java/org/terasology/cities/common/Edges.java
// public final class Edges {
//
// private Edges() {
// // no instances
// }
//
// public static Vector2i getCorner(BlockAreac rc, Orientation o) {
//
// int dx = o.direction().x() + 1; // [0..2]
// int dy = o.direction().y() + 1; // [0..2]
//
// int x = rc.minX() + (rc.getSizeX() - 1) * dx / 2;
// int y = rc.minY() + (rc.getSizeY() - 1) * dy / 2;
//
// return new Vector2i(x, y);
// }
//
// public static int getDistanceToBorder(BlockAreac rc, int x, int z) {
// int rx = x - rc.minX();
// int rz = z - rc.minY();
//
// // distance to border along both axes
// int borderDistX = Math.min(rx, rc.getSizeX() - 1 - rx);
// int borderDistZ = Math.min(rz, rc.getSizeY() - 1 - rz);
//
// int dist = Math.min(borderDistX, borderDistZ);
// return dist;
// }
//
// public static float getDistanceToCorner(BlockAreac rc, int x, int y) {
// return (float) Math.sqrt(getDistanceToCorner(rc, x, y));
// }
//
// public static int getDistanceToCornerSq(BlockAreac rc, int x, int y) {
// int dx = Math.min(x - rc.minX(), rc.maxX() - x);
// int dy = Math.min(y - rc.minY(), rc.maxY() - y);
// return dx * dx + dy * dy;
// }
//
// public static Line2f getEdge(BlockAreac rc, Orientation o) {
//
// Vector2i p0 = getCorner(rc, o.getRotated(-45));
// Vector2i p1 = getCorner(rc, o.getRotated(45));
// return new Line2f(p0.x(), p0.y(), p1.x(), p1.y());
// }
// }
//
// Path: src/main/java/org/terasology/cities/door/SimpleDoor.java
// public class SimpleDoor implements Door {
//
// private final Orientation orientation;
// private final int baseHeight;
// private final int topHeight;
// private final Vector2i pos = new Vector2i();
//
// /**
// * @param orientation the orientation
// * @param pos the position in the XZ plane
// * @param baseHeight the height at the bottom
// * @param topHeight the height at the top
// */
// public SimpleDoor(Orientation orientation, Vector2ic pos, int baseHeight, int topHeight) {
// this.orientation = orientation;
// this.pos.set(pos);
// this.baseHeight = baseHeight;
// this.topHeight = topHeight;
// }
//
// /**
// * @return the orientation
// */
// public Orientation getOrientation() {
// return this.orientation;
// }
//
// /**
// * @return the door position
// */
// public Vector2ic getPos() {
// return this.pos;
// }
//
// /**
// * @return the baseHeight
// */
// public int getBaseHeight() {
// return this.baseHeight;
// }
//
// /**
// * @return the topHeight
// */
// public int getTopHeight() {
// return this.topHeight;
// }
// }
//
// Path: src/main/java/org/terasology/cities/model/roof/BattlementRoof.java
// public class BattlementRoof extends FlatRoof {
//
// /**
// * @param baseRect the building rectangle (must be fully inside <code>withEaves</code>).
// * @param withEaves the roof area including eaves (=overhang)
// * @param baseHeight the base height of the roof
// * @param merlonHeight the height of the border
// */
// public BattlementRoof(BlockAreac baseRect, BlockAreac withEaves, int baseHeight, int merlonHeight) {
// super(baseRect, withEaves, baseHeight, merlonHeight);
// }
//
// /**
// * @param lx x in local (roof area) coordinates
// * @param lz z in local (roof area) coordinates
// * @return the borderHeight
// */
// @Override
// public int getBorderHeight(int lx, int lz) {
// if (lx % 2 == 1) {
// return 0;
// }
//
// if (lz % 2 == 1) {
// return 0;
// }
//
// return super.getBorderHeight(lx, lz);
// }
// }
//
// Path: src/main/java/org/terasology/cities/model/roof/Roof.java
// public interface Roof {
//
//
// }
| import org.joml.Vector2i;
import org.terasology.cities.common.Edges;
import org.terasology.cities.door.SimpleDoor;
import org.terasology.cities.model.roof.BattlementRoof;
import org.terasology.cities.model.roof.Roof;
import org.terasology.commonworld.Orientation;
import org.terasology.engine.world.block.BlockArea;
import org.terasology.engine.world.block.BlockAreac; | /*
* Copyright 2015 MovingBlocks
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.terasology.cities.bldg;
/**
* A simple tower
*/
public class SimpleTower extends DefaultBuilding implements Tower {
private BlockArea shape = new BlockArea(BlockArea.INVALID);
private RectBuildingPart room;
/**
* @param orient the orientation of the building
* @param layout the building layout
* @param baseHeight the height of the floor level
* @param wallHeight the building height above the floor level
*/
public SimpleTower(Orientation orient, BlockAreac layout, int baseHeight, int wallHeight) {
super(orient);
this.shape.set(layout);
BlockArea roofArea = layout.expand(1, 1,new BlockArea(BlockArea.INVALID)); | // Path: src/main/java/org/terasology/cities/common/Edges.java
// public final class Edges {
//
// private Edges() {
// // no instances
// }
//
// public static Vector2i getCorner(BlockAreac rc, Orientation o) {
//
// int dx = o.direction().x() + 1; // [0..2]
// int dy = o.direction().y() + 1; // [0..2]
//
// int x = rc.minX() + (rc.getSizeX() - 1) * dx / 2;
// int y = rc.minY() + (rc.getSizeY() - 1) * dy / 2;
//
// return new Vector2i(x, y);
// }
//
// public static int getDistanceToBorder(BlockAreac rc, int x, int z) {
// int rx = x - rc.minX();
// int rz = z - rc.minY();
//
// // distance to border along both axes
// int borderDistX = Math.min(rx, rc.getSizeX() - 1 - rx);
// int borderDistZ = Math.min(rz, rc.getSizeY() - 1 - rz);
//
// int dist = Math.min(borderDistX, borderDistZ);
// return dist;
// }
//
// public static float getDistanceToCorner(BlockAreac rc, int x, int y) {
// return (float) Math.sqrt(getDistanceToCorner(rc, x, y));
// }
//
// public static int getDistanceToCornerSq(BlockAreac rc, int x, int y) {
// int dx = Math.min(x - rc.minX(), rc.maxX() - x);
// int dy = Math.min(y - rc.minY(), rc.maxY() - y);
// return dx * dx + dy * dy;
// }
//
// public static Line2f getEdge(BlockAreac rc, Orientation o) {
//
// Vector2i p0 = getCorner(rc, o.getRotated(-45));
// Vector2i p1 = getCorner(rc, o.getRotated(45));
// return new Line2f(p0.x(), p0.y(), p1.x(), p1.y());
// }
// }
//
// Path: src/main/java/org/terasology/cities/door/SimpleDoor.java
// public class SimpleDoor implements Door {
//
// private final Orientation orientation;
// private final int baseHeight;
// private final int topHeight;
// private final Vector2i pos = new Vector2i();
//
// /**
// * @param orientation the orientation
// * @param pos the position in the XZ plane
// * @param baseHeight the height at the bottom
// * @param topHeight the height at the top
// */
// public SimpleDoor(Orientation orientation, Vector2ic pos, int baseHeight, int topHeight) {
// this.orientation = orientation;
// this.pos.set(pos);
// this.baseHeight = baseHeight;
// this.topHeight = topHeight;
// }
//
// /**
// * @return the orientation
// */
// public Orientation getOrientation() {
// return this.orientation;
// }
//
// /**
// * @return the door position
// */
// public Vector2ic getPos() {
// return this.pos;
// }
//
// /**
// * @return the baseHeight
// */
// public int getBaseHeight() {
// return this.baseHeight;
// }
//
// /**
// * @return the topHeight
// */
// public int getTopHeight() {
// return this.topHeight;
// }
// }
//
// Path: src/main/java/org/terasology/cities/model/roof/BattlementRoof.java
// public class BattlementRoof extends FlatRoof {
//
// /**
// * @param baseRect the building rectangle (must be fully inside <code>withEaves</code>).
// * @param withEaves the roof area including eaves (=overhang)
// * @param baseHeight the base height of the roof
// * @param merlonHeight the height of the border
// */
// public BattlementRoof(BlockAreac baseRect, BlockAreac withEaves, int baseHeight, int merlonHeight) {
// super(baseRect, withEaves, baseHeight, merlonHeight);
// }
//
// /**
// * @param lx x in local (roof area) coordinates
// * @param lz z in local (roof area) coordinates
// * @return the borderHeight
// */
// @Override
// public int getBorderHeight(int lx, int lz) {
// if (lx % 2 == 1) {
// return 0;
// }
//
// if (lz % 2 == 1) {
// return 0;
// }
//
// return super.getBorderHeight(lx, lz);
// }
// }
//
// Path: src/main/java/org/terasology/cities/model/roof/Roof.java
// public interface Roof {
//
//
// }
// Path: src/main/java/org/terasology/cities/bldg/SimpleTower.java
import org.joml.Vector2i;
import org.terasology.cities.common.Edges;
import org.terasology.cities.door.SimpleDoor;
import org.terasology.cities.model.roof.BattlementRoof;
import org.terasology.cities.model.roof.Roof;
import org.terasology.commonworld.Orientation;
import org.terasology.engine.world.block.BlockArea;
import org.terasology.engine.world.block.BlockAreac;
/*
* Copyright 2015 MovingBlocks
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.terasology.cities.bldg;
/**
* A simple tower
*/
public class SimpleTower extends DefaultBuilding implements Tower {
private BlockArea shape = new BlockArea(BlockArea.INVALID);
private RectBuildingPart room;
/**
* @param orient the orientation of the building
* @param layout the building layout
* @param baseHeight the height of the floor level
* @param wallHeight the building height above the floor level
*/
public SimpleTower(Orientation orient, BlockAreac layout, int baseHeight, int wallHeight) {
super(orient);
this.shape.set(layout);
BlockArea roofArea = layout.expand(1, 1,new BlockArea(BlockArea.INVALID)); | Roof roof = new BattlementRoof(layout, roofArea, baseHeight + wallHeight, 1); |
Terasology/Cities | src/main/java/org/terasology/cities/bldg/StaircaseBuildingPart.java | // Path: src/main/java/org/terasology/cities/model/roof/Roof.java
// public interface Roof {
//
//
// }
| import org.terasology.cities.model.roof.Roof;
import org.terasology.commonworld.Orientation;
import org.terasology.engine.world.block.BlockArea;
import org.terasology.engine.world.block.BlockAreac; | /*
* Copyright 2015 MovingBlocks
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.terasology.cities.bldg;
/**
*
*/
public class StaircaseBuildingPart extends RectBuildingPart {
private Orientation orientation;
private BlockArea layout = new BlockArea(BlockArea.INVALID);
| // Path: src/main/java/org/terasology/cities/model/roof/Roof.java
// public interface Roof {
//
//
// }
// Path: src/main/java/org/terasology/cities/bldg/StaircaseBuildingPart.java
import org.terasology.cities.model.roof.Roof;
import org.terasology.commonworld.Orientation;
import org.terasology.engine.world.block.BlockArea;
import org.terasology.engine.world.block.BlockAreac;
/*
* Copyright 2015 MovingBlocks
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.terasology.cities.bldg;
/**
*
*/
public class StaircaseBuildingPart extends RectBuildingPart {
private Orientation orientation;
private BlockArea layout = new BlockArea(BlockArea.INVALID);
| public StaircaseBuildingPart(BlockAreac layout, Orientation o, Roof roof, int baseHeight, int wallHeight) { |
Terasology/Cities | src/test/java/org/terasology/cities/bldg/DebugRasterTarget.java | // Path: src/main/java/org/terasology/cities/BlockType.java
// public interface BlockType {
// // empty marker
// }
//
// Path: src/main/java/org/terasology/cities/DefaultBlockType.java
// public enum DefaultBlockType implements BlockType {
//
// /**
// * Air
// */
// AIR,
//
// /**
// * Windows
// */
// WINDOW_GLASS,
//
// /**
// * A single-block door element
// */
// SIMPLE_DOOR,
//
// /**
// * A two-folded wing door
// */
// WING_DOOR,
//
// /**
// * Fill material under the surface of a road
// */
// ROAD_FILL,
//
// /**
// * Surface of a road (asphalt)
// */
// ROAD_SURFACE,
//
// /**
// * Empty space in a lot
// */
// LOT_EMPTY,
//
// /**
// * A simple building's floor
// */
// BUILDING_FLOOR,
//
// /**
// * A simple building's foundation
// */
// BUILDING_FOUNDATION,
//
// /**
// * A simple building wall
// */
// BUILDING_WALL,
//
// /**
// * Flat roof
// */
// ROOF_FLAT,
//
// /**
// * Hip roof
// */
// ROOF_HIP,
//
// /**
// * Dome roof
// */
// ROOF_DOME,
//
// /**
// * The roof gable for saddle roofs
// */
// ROOF_GABLE,
//
// /**
// * Saddle roof
// */
// ROOF_SADDLE,
//
// /**
// * Tower stone
// */
// TOWER_WALL,
//
// /**
// * Fence
// */
// FENCE,
//
// /**
// * Fence gate
// */
// FENCE_GATE,
//
// /**
// * Tower staircase
// */
// TOWER_STAIRS,
//
// /**
// * A barrel
// */
// BARREL,
//
// /**
// * A torch
// */
// TORCH,
//
// /**
// * Pillar material
// */
// PILLAR_TOP,
//
// /**
// * Pillar material
// */
// PILLAR_MIDDLE,
//
// /**
// * Pillar material
// */
// PILLAR_BASE,
//
// /**
// * A ladder element
// */
// LADDER
// }
//
// Path: src/main/java/org/terasology/cities/raster/RasterTarget.java
// public interface RasterTarget {
//
// /**
// * @param x x in world coords
// * @param y y in world coords
// * @param z z in world coords
// * @param type the block type
// */
// void setBlock(int x, int y, int z, BlockType type);
//
// /**
// * @param pos the position in world coords
// * @param type the block type
// */
// default void setBlock(Vector3ic pos, BlockType type) {
// setBlock(pos.x(), pos.y(), pos.z(), type);
// }
//
// /**
// * @param x x in world coords
// * @param y y in world coords
// * @param z z in world coords
// * @param type the block type
// * @param side the sides (used to find the correct block from the family)
// */
// void setBlock(int x, int y, int z, BlockType type, Set<Side> side);
//
// /**
// * @param pos the position in world coords
// * @param type the block type
// * @param sides the sides (used to find the correct block from the family)
// */
// default void setBlock(Vector3ic pos, BlockType type, Set<Side> sides) {
// setBlock(pos.x(), pos.y(), pos.z(), type, sides);
// }
//
// /**
// * @return the maximum drawing height
// */
// default int getMaxHeight() {
// return getAffectedRegion().maxY();
// }
//
// /**
// * @return the maximum drawing height
// */
// default int getMinHeight() {
// return getAffectedRegion().minY();
// }
//
// /**
// * @return the XZ area that is drawn by this raster target
// */
// BlockAreac getAffectedArea();
//
// /**
// * @return the region that is drawn by this raster target
// */
// BlockRegionc getAffectedRegion();
// }
| import java.util.Set;
import org.terasology.cities.BlockType;
import org.terasology.cities.DefaultBlockType;
import org.terasology.cities.raster.RasterTarget;
import org.terasology.engine.math.Side;
import org.terasology.engine.world.block.BlockArea;
import org.terasology.engine.world.block.BlockAreac;
import org.terasology.engine.world.block.BlockRegion;
import org.terasology.engine.world.chunks.Chunks;
import org.terasology.engine.world.chunks.blockdata.TeraArray;
import org.terasology.engine.world.chunks.blockdata.TeraDenseArray16Bit;
import java.util.AbstractList;
import java.util.ArrayList;
import java.util.List; | /*
* Copyright 2015 MovingBlocks
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.terasology.cities.bldg;
/**
*
*/
public class DebugRasterTarget implements RasterTarget {
private final BlockAreac area;
private final BlockRegion region;
private final TeraArray data; | // Path: src/main/java/org/terasology/cities/BlockType.java
// public interface BlockType {
// // empty marker
// }
//
// Path: src/main/java/org/terasology/cities/DefaultBlockType.java
// public enum DefaultBlockType implements BlockType {
//
// /**
// * Air
// */
// AIR,
//
// /**
// * Windows
// */
// WINDOW_GLASS,
//
// /**
// * A single-block door element
// */
// SIMPLE_DOOR,
//
// /**
// * A two-folded wing door
// */
// WING_DOOR,
//
// /**
// * Fill material under the surface of a road
// */
// ROAD_FILL,
//
// /**
// * Surface of a road (asphalt)
// */
// ROAD_SURFACE,
//
// /**
// * Empty space in a lot
// */
// LOT_EMPTY,
//
// /**
// * A simple building's floor
// */
// BUILDING_FLOOR,
//
// /**
// * A simple building's foundation
// */
// BUILDING_FOUNDATION,
//
// /**
// * A simple building wall
// */
// BUILDING_WALL,
//
// /**
// * Flat roof
// */
// ROOF_FLAT,
//
// /**
// * Hip roof
// */
// ROOF_HIP,
//
// /**
// * Dome roof
// */
// ROOF_DOME,
//
// /**
// * The roof gable for saddle roofs
// */
// ROOF_GABLE,
//
// /**
// * Saddle roof
// */
// ROOF_SADDLE,
//
// /**
// * Tower stone
// */
// TOWER_WALL,
//
// /**
// * Fence
// */
// FENCE,
//
// /**
// * Fence gate
// */
// FENCE_GATE,
//
// /**
// * Tower staircase
// */
// TOWER_STAIRS,
//
// /**
// * A barrel
// */
// BARREL,
//
// /**
// * A torch
// */
// TORCH,
//
// /**
// * Pillar material
// */
// PILLAR_TOP,
//
// /**
// * Pillar material
// */
// PILLAR_MIDDLE,
//
// /**
// * Pillar material
// */
// PILLAR_BASE,
//
// /**
// * A ladder element
// */
// LADDER
// }
//
// Path: src/main/java/org/terasology/cities/raster/RasterTarget.java
// public interface RasterTarget {
//
// /**
// * @param x x in world coords
// * @param y y in world coords
// * @param z z in world coords
// * @param type the block type
// */
// void setBlock(int x, int y, int z, BlockType type);
//
// /**
// * @param pos the position in world coords
// * @param type the block type
// */
// default void setBlock(Vector3ic pos, BlockType type) {
// setBlock(pos.x(), pos.y(), pos.z(), type);
// }
//
// /**
// * @param x x in world coords
// * @param y y in world coords
// * @param z z in world coords
// * @param type the block type
// * @param side the sides (used to find the correct block from the family)
// */
// void setBlock(int x, int y, int z, BlockType type, Set<Side> side);
//
// /**
// * @param pos the position in world coords
// * @param type the block type
// * @param sides the sides (used to find the correct block from the family)
// */
// default void setBlock(Vector3ic pos, BlockType type, Set<Side> sides) {
// setBlock(pos.x(), pos.y(), pos.z(), type, sides);
// }
//
// /**
// * @return the maximum drawing height
// */
// default int getMaxHeight() {
// return getAffectedRegion().maxY();
// }
//
// /**
// * @return the maximum drawing height
// */
// default int getMinHeight() {
// return getAffectedRegion().minY();
// }
//
// /**
// * @return the XZ area that is drawn by this raster target
// */
// BlockAreac getAffectedArea();
//
// /**
// * @return the region that is drawn by this raster target
// */
// BlockRegionc getAffectedRegion();
// }
// Path: src/test/java/org/terasology/cities/bldg/DebugRasterTarget.java
import java.util.Set;
import org.terasology.cities.BlockType;
import org.terasology.cities.DefaultBlockType;
import org.terasology.cities.raster.RasterTarget;
import org.terasology.engine.math.Side;
import org.terasology.engine.world.block.BlockArea;
import org.terasology.engine.world.block.BlockAreac;
import org.terasology.engine.world.block.BlockRegion;
import org.terasology.engine.world.chunks.Chunks;
import org.terasology.engine.world.chunks.blockdata.TeraArray;
import org.terasology.engine.world.chunks.blockdata.TeraDenseArray16Bit;
import java.util.AbstractList;
import java.util.ArrayList;
import java.util.List;
/*
* Copyright 2015 MovingBlocks
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.terasology.cities.bldg;
/**
*
*/
public class DebugRasterTarget implements RasterTarget {
private final BlockAreac area;
private final BlockRegion region;
private final TeraArray data; | private final List<BlockType> mapping = new ArrayList<BlockType>(); |
Terasology/Cities | src/main/java/org/terasology/cities/bldg/HollowBuildingPart.java | // Path: src/main/java/org/terasology/cities/bldg/shape/RectangularBase.java
// public interface RectangularBase {
// BlockAreac getShape();
// }
//
// Path: src/main/java/org/terasology/cities/model/roof/Roof.java
// public interface Roof {
//
//
// }
| import org.terasology.cities.bldg.shape.RectangularBase;
import org.terasology.cities.model.roof.Roof;
import org.terasology.engine.world.block.BlockArea;
import org.terasology.engine.world.block.BlockAreac; | /*
* Copyright 2015 MovingBlocks
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.terasology.cities.bldg;
/**
*
*/
public class HollowBuildingPart extends AbstractBuildingPart implements RectangularBase {
private final int arcRadius;
private final BlockArea layout = new BlockArea(BlockArea.INVALID);
| // Path: src/main/java/org/terasology/cities/bldg/shape/RectangularBase.java
// public interface RectangularBase {
// BlockAreac getShape();
// }
//
// Path: src/main/java/org/terasology/cities/model/roof/Roof.java
// public interface Roof {
//
//
// }
// Path: src/main/java/org/terasology/cities/bldg/HollowBuildingPart.java
import org.terasology.cities.bldg.shape.RectangularBase;
import org.terasology.cities.model.roof.Roof;
import org.terasology.engine.world.block.BlockArea;
import org.terasology.engine.world.block.BlockAreac;
/*
* Copyright 2015 MovingBlocks
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.terasology.cities.bldg;
/**
*
*/
public class HollowBuildingPart extends AbstractBuildingPart implements RectangularBase {
private final int arcRadius;
private final BlockArea layout = new BlockArea(BlockArea.INVALID);
| public HollowBuildingPart(BlockAreac layout, Roof roof, int baseHeight, int wallHeight, int arcRadius) { |
Terasology/Cities | src/main/java/org/terasology/cities/deco/Ladder.java | // Path: src/main/java/org/terasology/cities/DefaultBlockType.java
// public enum DefaultBlockType implements BlockType {
//
// /**
// * Air
// */
// AIR,
//
// /**
// * Windows
// */
// WINDOW_GLASS,
//
// /**
// * A single-block door element
// */
// SIMPLE_DOOR,
//
// /**
// * A two-folded wing door
// */
// WING_DOOR,
//
// /**
// * Fill material under the surface of a road
// */
// ROAD_FILL,
//
// /**
// * Surface of a road (asphalt)
// */
// ROAD_SURFACE,
//
// /**
// * Empty space in a lot
// */
// LOT_EMPTY,
//
// /**
// * A simple building's floor
// */
// BUILDING_FLOOR,
//
// /**
// * A simple building's foundation
// */
// BUILDING_FOUNDATION,
//
// /**
// * A simple building wall
// */
// BUILDING_WALL,
//
// /**
// * Flat roof
// */
// ROOF_FLAT,
//
// /**
// * Hip roof
// */
// ROOF_HIP,
//
// /**
// * Dome roof
// */
// ROOF_DOME,
//
// /**
// * The roof gable for saddle roofs
// */
// ROOF_GABLE,
//
// /**
// * Saddle roof
// */
// ROOF_SADDLE,
//
// /**
// * Tower stone
// */
// TOWER_WALL,
//
// /**
// * Fence
// */
// FENCE,
//
// /**
// * Fence gate
// */
// FENCE_GATE,
//
// /**
// * Tower staircase
// */
// TOWER_STAIRS,
//
// /**
// * A barrel
// */
// BARREL,
//
// /**
// * A torch
// */
// TORCH,
//
// /**
// * Pillar material
// */
// PILLAR_TOP,
//
// /**
// * Pillar material
// */
// PILLAR_MIDDLE,
//
// /**
// * Pillar material
// */
// PILLAR_BASE,
//
// /**
// * A ladder element
// */
// LADDER
// }
| import org.joml.Vector3ic;
import org.terasology.cities.DefaultBlockType;
import org.terasology.commonworld.Orientation;
import org.terasology.engine.math.Side;
import java.util.Collections; | /*
* Copyright 2015 MovingBlocks
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.terasology.cities.deco;
/**
* A straight, rising ladder made of a single block type
*/
public class Ladder extends ColumnDecoration {
/**
* @param basePos the position of the base block
* @param o the orientation of the ladder (must be cardinal)
* @param height the height of the ladder
*/
public Ladder(Vector3ic basePos, Orientation o, int height) { | // Path: src/main/java/org/terasology/cities/DefaultBlockType.java
// public enum DefaultBlockType implements BlockType {
//
// /**
// * Air
// */
// AIR,
//
// /**
// * Windows
// */
// WINDOW_GLASS,
//
// /**
// * A single-block door element
// */
// SIMPLE_DOOR,
//
// /**
// * A two-folded wing door
// */
// WING_DOOR,
//
// /**
// * Fill material under the surface of a road
// */
// ROAD_FILL,
//
// /**
// * Surface of a road (asphalt)
// */
// ROAD_SURFACE,
//
// /**
// * Empty space in a lot
// */
// LOT_EMPTY,
//
// /**
// * A simple building's floor
// */
// BUILDING_FLOOR,
//
// /**
// * A simple building's foundation
// */
// BUILDING_FOUNDATION,
//
// /**
// * A simple building wall
// */
// BUILDING_WALL,
//
// /**
// * Flat roof
// */
// ROOF_FLAT,
//
// /**
// * Hip roof
// */
// ROOF_HIP,
//
// /**
// * Dome roof
// */
// ROOF_DOME,
//
// /**
// * The roof gable for saddle roofs
// */
// ROOF_GABLE,
//
// /**
// * Saddle roof
// */
// ROOF_SADDLE,
//
// /**
// * Tower stone
// */
// TOWER_WALL,
//
// /**
// * Fence
// */
// FENCE,
//
// /**
// * Fence gate
// */
// FENCE_GATE,
//
// /**
// * Tower staircase
// */
// TOWER_STAIRS,
//
// /**
// * A barrel
// */
// BARREL,
//
// /**
// * A torch
// */
// TORCH,
//
// /**
// * Pillar material
// */
// PILLAR_TOP,
//
// /**
// * Pillar material
// */
// PILLAR_MIDDLE,
//
// /**
// * Pillar material
// */
// PILLAR_BASE,
//
// /**
// * A ladder element
// */
// LADDER
// }
// Path: src/main/java/org/terasology/cities/deco/Ladder.java
import org.joml.Vector3ic;
import org.terasology.cities.DefaultBlockType;
import org.terasology.commonworld.Orientation;
import org.terasology.engine.math.Side;
import java.util.Collections;
/*
* Copyright 2015 MovingBlocks
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.terasology.cities.deco;
/**
* A straight, rising ladder made of a single block type
*/
public class Ladder extends ColumnDecoration {
/**
* @param basePos the position of the base block
* @param o the orientation of the ladder (must be cardinal)
* @param height the height of the ladder
*/
public Ladder(Vector3ic basePos, Orientation o, int height) { | super(Collections.nCopies(height, DefaultBlockType.LADDER), |
Terasology/Cities | src/main/java/org/terasology/cities/raster/BuildingPens.java | // Path: src/main/java/org/terasology/cities/BlockType.java
// public interface BlockType {
// // empty marker
// }
//
// Path: src/main/java/org/terasology/cities/DefaultBlockType.java
// public enum DefaultBlockType implements BlockType {
//
// /**
// * Air
// */
// AIR,
//
// /**
// * Windows
// */
// WINDOW_GLASS,
//
// /**
// * A single-block door element
// */
// SIMPLE_DOOR,
//
// /**
// * A two-folded wing door
// */
// WING_DOOR,
//
// /**
// * Fill material under the surface of a road
// */
// ROAD_FILL,
//
// /**
// * Surface of a road (asphalt)
// */
// ROAD_SURFACE,
//
// /**
// * Empty space in a lot
// */
// LOT_EMPTY,
//
// /**
// * A simple building's floor
// */
// BUILDING_FLOOR,
//
// /**
// * A simple building's foundation
// */
// BUILDING_FOUNDATION,
//
// /**
// * A simple building wall
// */
// BUILDING_WALL,
//
// /**
// * Flat roof
// */
// ROOF_FLAT,
//
// /**
// * Hip roof
// */
// ROOF_HIP,
//
// /**
// * Dome roof
// */
// ROOF_DOME,
//
// /**
// * The roof gable for saddle roofs
// */
// ROOF_GABLE,
//
// /**
// * Saddle roof
// */
// ROOF_SADDLE,
//
// /**
// * Tower stone
// */
// TOWER_WALL,
//
// /**
// * Fence
// */
// FENCE,
//
// /**
// * Fence gate
// */
// FENCE_GATE,
//
// /**
// * Tower staircase
// */
// TOWER_STAIRS,
//
// /**
// * A barrel
// */
// BARREL,
//
// /**
// * A torch
// */
// TORCH,
//
// /**
// * Pillar material
// */
// PILLAR_TOP,
//
// /**
// * Pillar material
// */
// PILLAR_MIDDLE,
//
// /**
// * Pillar material
// */
// PILLAR_BASE,
//
// /**
// * A ladder element
// */
// LADDER
// }
| import org.terasology.cities.BlockType;
import org.terasology.cities.DefaultBlockType;
import org.terasology.commonworld.heightmap.HeightMap; | /*
* Copyright 2015 MovingBlocks
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.terasology.cities.raster;
/**
* Provides {@link Pen} instances for building-related rasterization.
*/
public final class BuildingPens {
private BuildingPens() {
// no instances
}
/**
* @param target the target to write to
* @param terrainHeightMap the terrain height map
* @param baseHeight the floor level
* @param floor the floor block type
* @return a new instance
*/ | // Path: src/main/java/org/terasology/cities/BlockType.java
// public interface BlockType {
// // empty marker
// }
//
// Path: src/main/java/org/terasology/cities/DefaultBlockType.java
// public enum DefaultBlockType implements BlockType {
//
// /**
// * Air
// */
// AIR,
//
// /**
// * Windows
// */
// WINDOW_GLASS,
//
// /**
// * A single-block door element
// */
// SIMPLE_DOOR,
//
// /**
// * A two-folded wing door
// */
// WING_DOOR,
//
// /**
// * Fill material under the surface of a road
// */
// ROAD_FILL,
//
// /**
// * Surface of a road (asphalt)
// */
// ROAD_SURFACE,
//
// /**
// * Empty space in a lot
// */
// LOT_EMPTY,
//
// /**
// * A simple building's floor
// */
// BUILDING_FLOOR,
//
// /**
// * A simple building's foundation
// */
// BUILDING_FOUNDATION,
//
// /**
// * A simple building wall
// */
// BUILDING_WALL,
//
// /**
// * Flat roof
// */
// ROOF_FLAT,
//
// /**
// * Hip roof
// */
// ROOF_HIP,
//
// /**
// * Dome roof
// */
// ROOF_DOME,
//
// /**
// * The roof gable for saddle roofs
// */
// ROOF_GABLE,
//
// /**
// * Saddle roof
// */
// ROOF_SADDLE,
//
// /**
// * Tower stone
// */
// TOWER_WALL,
//
// /**
// * Fence
// */
// FENCE,
//
// /**
// * Fence gate
// */
// FENCE_GATE,
//
// /**
// * Tower staircase
// */
// TOWER_STAIRS,
//
// /**
// * A barrel
// */
// BARREL,
//
// /**
// * A torch
// */
// TORCH,
//
// /**
// * Pillar material
// */
// PILLAR_TOP,
//
// /**
// * Pillar material
// */
// PILLAR_MIDDLE,
//
// /**
// * Pillar material
// */
// PILLAR_BASE,
//
// /**
// * A ladder element
// */
// LADDER
// }
// Path: src/main/java/org/terasology/cities/raster/BuildingPens.java
import org.terasology.cities.BlockType;
import org.terasology.cities.DefaultBlockType;
import org.terasology.commonworld.heightmap.HeightMap;
/*
* Copyright 2015 MovingBlocks
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.terasology.cities.raster;
/**
* Provides {@link Pen} instances for building-related rasterization.
*/
public final class BuildingPens {
private BuildingPens() {
// no instances
}
/**
* @param target the target to write to
* @param terrainHeightMap the terrain height map
* @param baseHeight the floor level
* @param floor the floor block type
* @return a new instance
*/ | public static Pen floorPen(RasterTarget target, HeightMap terrainHeightMap, int baseHeight, BlockType floor) { |
Terasology/Cities | src/main/java/org/terasology/cities/raster/BuildingPens.java | // Path: src/main/java/org/terasology/cities/BlockType.java
// public interface BlockType {
// // empty marker
// }
//
// Path: src/main/java/org/terasology/cities/DefaultBlockType.java
// public enum DefaultBlockType implements BlockType {
//
// /**
// * Air
// */
// AIR,
//
// /**
// * Windows
// */
// WINDOW_GLASS,
//
// /**
// * A single-block door element
// */
// SIMPLE_DOOR,
//
// /**
// * A two-folded wing door
// */
// WING_DOOR,
//
// /**
// * Fill material under the surface of a road
// */
// ROAD_FILL,
//
// /**
// * Surface of a road (asphalt)
// */
// ROAD_SURFACE,
//
// /**
// * Empty space in a lot
// */
// LOT_EMPTY,
//
// /**
// * A simple building's floor
// */
// BUILDING_FLOOR,
//
// /**
// * A simple building's foundation
// */
// BUILDING_FOUNDATION,
//
// /**
// * A simple building wall
// */
// BUILDING_WALL,
//
// /**
// * Flat roof
// */
// ROOF_FLAT,
//
// /**
// * Hip roof
// */
// ROOF_HIP,
//
// /**
// * Dome roof
// */
// ROOF_DOME,
//
// /**
// * The roof gable for saddle roofs
// */
// ROOF_GABLE,
//
// /**
// * Saddle roof
// */
// ROOF_SADDLE,
//
// /**
// * Tower stone
// */
// TOWER_WALL,
//
// /**
// * Fence
// */
// FENCE,
//
// /**
// * Fence gate
// */
// FENCE_GATE,
//
// /**
// * Tower staircase
// */
// TOWER_STAIRS,
//
// /**
// * A barrel
// */
// BARREL,
//
// /**
// * A torch
// */
// TORCH,
//
// /**
// * Pillar material
// */
// PILLAR_TOP,
//
// /**
// * Pillar material
// */
// PILLAR_MIDDLE,
//
// /**
// * Pillar material
// */
// PILLAR_BASE,
//
// /**
// * A ladder element
// */
// LADDER
// }
| import org.terasology.cities.BlockType;
import org.terasology.cities.DefaultBlockType;
import org.terasology.commonworld.heightmap.HeightMap; | /*
* Copyright 2015 MovingBlocks
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.terasology.cities.raster;
/**
* Provides {@link Pen} instances for building-related rasterization.
*/
public final class BuildingPens {
private BuildingPens() {
// no instances
}
/**
* @param target the target to write to
* @param terrainHeightMap the terrain height map
* @param baseHeight the floor level
* @param floor the floor block type
* @return a new instance
*/
public static Pen floorPen(RasterTarget target, HeightMap terrainHeightMap, int baseHeight, BlockType floor) {
return new AbstractPen(target.getAffectedArea()) {
@Override
public void draw(int x, int z) {
int terrain = terrainHeightMap.apply(x, z);
int floorLevel = baseHeight - 1;
int y = Math.max(target.getMinHeight(), terrain);
if (y > target.getMaxHeight()) {
return;
}
// put foundation material below between terrain and floor level
while (y < floorLevel) { | // Path: src/main/java/org/terasology/cities/BlockType.java
// public interface BlockType {
// // empty marker
// }
//
// Path: src/main/java/org/terasology/cities/DefaultBlockType.java
// public enum DefaultBlockType implements BlockType {
//
// /**
// * Air
// */
// AIR,
//
// /**
// * Windows
// */
// WINDOW_GLASS,
//
// /**
// * A single-block door element
// */
// SIMPLE_DOOR,
//
// /**
// * A two-folded wing door
// */
// WING_DOOR,
//
// /**
// * Fill material under the surface of a road
// */
// ROAD_FILL,
//
// /**
// * Surface of a road (asphalt)
// */
// ROAD_SURFACE,
//
// /**
// * Empty space in a lot
// */
// LOT_EMPTY,
//
// /**
// * A simple building's floor
// */
// BUILDING_FLOOR,
//
// /**
// * A simple building's foundation
// */
// BUILDING_FOUNDATION,
//
// /**
// * A simple building wall
// */
// BUILDING_WALL,
//
// /**
// * Flat roof
// */
// ROOF_FLAT,
//
// /**
// * Hip roof
// */
// ROOF_HIP,
//
// /**
// * Dome roof
// */
// ROOF_DOME,
//
// /**
// * The roof gable for saddle roofs
// */
// ROOF_GABLE,
//
// /**
// * Saddle roof
// */
// ROOF_SADDLE,
//
// /**
// * Tower stone
// */
// TOWER_WALL,
//
// /**
// * Fence
// */
// FENCE,
//
// /**
// * Fence gate
// */
// FENCE_GATE,
//
// /**
// * Tower staircase
// */
// TOWER_STAIRS,
//
// /**
// * A barrel
// */
// BARREL,
//
// /**
// * A torch
// */
// TORCH,
//
// /**
// * Pillar material
// */
// PILLAR_TOP,
//
// /**
// * Pillar material
// */
// PILLAR_MIDDLE,
//
// /**
// * Pillar material
// */
// PILLAR_BASE,
//
// /**
// * A ladder element
// */
// LADDER
// }
// Path: src/main/java/org/terasology/cities/raster/BuildingPens.java
import org.terasology.cities.BlockType;
import org.terasology.cities.DefaultBlockType;
import org.terasology.commonworld.heightmap.HeightMap;
/*
* Copyright 2015 MovingBlocks
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.terasology.cities.raster;
/**
* Provides {@link Pen} instances for building-related rasterization.
*/
public final class BuildingPens {
private BuildingPens() {
// no instances
}
/**
* @param target the target to write to
* @param terrainHeightMap the terrain height map
* @param baseHeight the floor level
* @param floor the floor block type
* @return a new instance
*/
public static Pen floorPen(RasterTarget target, HeightMap terrainHeightMap, int baseHeight, BlockType floor) {
return new AbstractPen(target.getAffectedArea()) {
@Override
public void draw(int x, int z) {
int terrain = terrainHeightMap.apply(x, z);
int floorLevel = baseHeight - 1;
int y = Math.max(target.getMinHeight(), terrain);
if (y > target.getMaxHeight()) {
return;
}
// put foundation material below between terrain and floor level
while (y < floorLevel) { | target.setBlock(x, y, z, DefaultBlockType.BUILDING_FOUNDATION); |
Terasology/Cities | src/main/java/org/terasology/cities/bldg/RoundBuildingPart.java | // Path: src/main/java/org/terasology/cities/bldg/shape/CircularBase.java
// public interface CircularBase {
//
// Circlef getShape();
// }
//
// Path: src/main/java/org/terasology/cities/model/roof/Roof.java
// public interface Roof {
//
//
// }
| import org.terasology.cities.bldg.shape.CircularBase;
import org.terasology.cities.model.roof.Roof;
import org.terasology.joml.geom.Circlef; | /*
* Copyright 2015 MovingBlocks
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.terasology.cities.bldg;
/**
*
*/
public class RoundBuildingPart extends AbstractBuildingPart implements CircularBase {
private Circlef layout = new Circlef();
| // Path: src/main/java/org/terasology/cities/bldg/shape/CircularBase.java
// public interface CircularBase {
//
// Circlef getShape();
// }
//
// Path: src/main/java/org/terasology/cities/model/roof/Roof.java
// public interface Roof {
//
//
// }
// Path: src/main/java/org/terasology/cities/bldg/RoundBuildingPart.java
import org.terasology.cities.bldg.shape.CircularBase;
import org.terasology.cities.model.roof.Roof;
import org.terasology.joml.geom.Circlef;
/*
* Copyright 2015 MovingBlocks
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.terasology.cities.bldg;
/**
*
*/
public class RoundBuildingPart extends AbstractBuildingPart implements CircularBase {
private Circlef layout = new Circlef();
| public RoundBuildingPart(Circlef layout, Roof roof, int baseHeight, int wallHeight) { |
Terasology/Cities | src/main/java/org/terasology/cities/deco/Pillar.java | // Path: src/main/java/org/terasology/cities/BlockType.java
// public interface BlockType {
// // empty marker
// }
//
// Path: src/main/java/org/terasology/cities/DefaultBlockType.java
// public enum DefaultBlockType implements BlockType {
//
// /**
// * Air
// */
// AIR,
//
// /**
// * Windows
// */
// WINDOW_GLASS,
//
// /**
// * A single-block door element
// */
// SIMPLE_DOOR,
//
// /**
// * A two-folded wing door
// */
// WING_DOOR,
//
// /**
// * Fill material under the surface of a road
// */
// ROAD_FILL,
//
// /**
// * Surface of a road (asphalt)
// */
// ROAD_SURFACE,
//
// /**
// * Empty space in a lot
// */
// LOT_EMPTY,
//
// /**
// * A simple building's floor
// */
// BUILDING_FLOOR,
//
// /**
// * A simple building's foundation
// */
// BUILDING_FOUNDATION,
//
// /**
// * A simple building wall
// */
// BUILDING_WALL,
//
// /**
// * Flat roof
// */
// ROOF_FLAT,
//
// /**
// * Hip roof
// */
// ROOF_HIP,
//
// /**
// * Dome roof
// */
// ROOF_DOME,
//
// /**
// * The roof gable for saddle roofs
// */
// ROOF_GABLE,
//
// /**
// * Saddle roof
// */
// ROOF_SADDLE,
//
// /**
// * Tower stone
// */
// TOWER_WALL,
//
// /**
// * Fence
// */
// FENCE,
//
// /**
// * Fence gate
// */
// FENCE_GATE,
//
// /**
// * Tower staircase
// */
// TOWER_STAIRS,
//
// /**
// * A barrel
// */
// BARREL,
//
// /**
// * A torch
// */
// TORCH,
//
// /**
// * Pillar material
// */
// PILLAR_TOP,
//
// /**
// * Pillar material
// */
// PILLAR_MIDDLE,
//
// /**
// * Pillar material
// */
// PILLAR_BASE,
//
// /**
// * A ladder element
// */
// LADDER
// }
| import com.google.common.collect.ImmutableList;
import org.joml.Vector3ic;
import org.terasology.cities.BlockType;
import org.terasology.cities.DefaultBlockType;
import org.terasology.engine.math.Side;
import java.util.Collections;
import java.util.List; | /*
* Copyright 2015 MovingBlocks
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.terasology.cities.deco;
public class Pillar extends ColumnDecoration {
/**
* @param basePos the position of the base block
* @param height the total height of the pillar
*/
public Pillar(Vector3ic basePos, int height) {
super(
createList(height),
Collections.nCopies(height, (Side) null),
basePos);
}
| // Path: src/main/java/org/terasology/cities/BlockType.java
// public interface BlockType {
// // empty marker
// }
//
// Path: src/main/java/org/terasology/cities/DefaultBlockType.java
// public enum DefaultBlockType implements BlockType {
//
// /**
// * Air
// */
// AIR,
//
// /**
// * Windows
// */
// WINDOW_GLASS,
//
// /**
// * A single-block door element
// */
// SIMPLE_DOOR,
//
// /**
// * A two-folded wing door
// */
// WING_DOOR,
//
// /**
// * Fill material under the surface of a road
// */
// ROAD_FILL,
//
// /**
// * Surface of a road (asphalt)
// */
// ROAD_SURFACE,
//
// /**
// * Empty space in a lot
// */
// LOT_EMPTY,
//
// /**
// * A simple building's floor
// */
// BUILDING_FLOOR,
//
// /**
// * A simple building's foundation
// */
// BUILDING_FOUNDATION,
//
// /**
// * A simple building wall
// */
// BUILDING_WALL,
//
// /**
// * Flat roof
// */
// ROOF_FLAT,
//
// /**
// * Hip roof
// */
// ROOF_HIP,
//
// /**
// * Dome roof
// */
// ROOF_DOME,
//
// /**
// * The roof gable for saddle roofs
// */
// ROOF_GABLE,
//
// /**
// * Saddle roof
// */
// ROOF_SADDLE,
//
// /**
// * Tower stone
// */
// TOWER_WALL,
//
// /**
// * Fence
// */
// FENCE,
//
// /**
// * Fence gate
// */
// FENCE_GATE,
//
// /**
// * Tower staircase
// */
// TOWER_STAIRS,
//
// /**
// * A barrel
// */
// BARREL,
//
// /**
// * A torch
// */
// TORCH,
//
// /**
// * Pillar material
// */
// PILLAR_TOP,
//
// /**
// * Pillar material
// */
// PILLAR_MIDDLE,
//
// /**
// * Pillar material
// */
// PILLAR_BASE,
//
// /**
// * A ladder element
// */
// LADDER
// }
// Path: src/main/java/org/terasology/cities/deco/Pillar.java
import com.google.common.collect.ImmutableList;
import org.joml.Vector3ic;
import org.terasology.cities.BlockType;
import org.terasology.cities.DefaultBlockType;
import org.terasology.engine.math.Side;
import java.util.Collections;
import java.util.List;
/*
* Copyright 2015 MovingBlocks
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.terasology.cities.deco;
public class Pillar extends ColumnDecoration {
/**
* @param basePos the position of the base block
* @param height the total height of the pillar
*/
public Pillar(Vector3ic basePos, int height) {
super(
createList(height),
Collections.nCopies(height, (Side) null),
basePos);
}
| private static List<BlockType> createList(int height) { |
Terasology/Cities | src/main/java/org/terasology/cities/deco/Pillar.java | // Path: src/main/java/org/terasology/cities/BlockType.java
// public interface BlockType {
// // empty marker
// }
//
// Path: src/main/java/org/terasology/cities/DefaultBlockType.java
// public enum DefaultBlockType implements BlockType {
//
// /**
// * Air
// */
// AIR,
//
// /**
// * Windows
// */
// WINDOW_GLASS,
//
// /**
// * A single-block door element
// */
// SIMPLE_DOOR,
//
// /**
// * A two-folded wing door
// */
// WING_DOOR,
//
// /**
// * Fill material under the surface of a road
// */
// ROAD_FILL,
//
// /**
// * Surface of a road (asphalt)
// */
// ROAD_SURFACE,
//
// /**
// * Empty space in a lot
// */
// LOT_EMPTY,
//
// /**
// * A simple building's floor
// */
// BUILDING_FLOOR,
//
// /**
// * A simple building's foundation
// */
// BUILDING_FOUNDATION,
//
// /**
// * A simple building wall
// */
// BUILDING_WALL,
//
// /**
// * Flat roof
// */
// ROOF_FLAT,
//
// /**
// * Hip roof
// */
// ROOF_HIP,
//
// /**
// * Dome roof
// */
// ROOF_DOME,
//
// /**
// * The roof gable for saddle roofs
// */
// ROOF_GABLE,
//
// /**
// * Saddle roof
// */
// ROOF_SADDLE,
//
// /**
// * Tower stone
// */
// TOWER_WALL,
//
// /**
// * Fence
// */
// FENCE,
//
// /**
// * Fence gate
// */
// FENCE_GATE,
//
// /**
// * Tower staircase
// */
// TOWER_STAIRS,
//
// /**
// * A barrel
// */
// BARREL,
//
// /**
// * A torch
// */
// TORCH,
//
// /**
// * Pillar material
// */
// PILLAR_TOP,
//
// /**
// * Pillar material
// */
// PILLAR_MIDDLE,
//
// /**
// * Pillar material
// */
// PILLAR_BASE,
//
// /**
// * A ladder element
// */
// LADDER
// }
| import com.google.common.collect.ImmutableList;
import org.joml.Vector3ic;
import org.terasology.cities.BlockType;
import org.terasology.cities.DefaultBlockType;
import org.terasology.engine.math.Side;
import java.util.Collections;
import java.util.List; | /*
* Copyright 2015 MovingBlocks
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.terasology.cities.deco;
public class Pillar extends ColumnDecoration {
/**
* @param basePos the position of the base block
* @param height the total height of the pillar
*/
public Pillar(Vector3ic basePos, int height) {
super(
createList(height),
Collections.nCopies(height, (Side) null),
basePos);
}
private static List<BlockType> createList(int height) {
return ImmutableList.<BlockType>builder() | // Path: src/main/java/org/terasology/cities/BlockType.java
// public interface BlockType {
// // empty marker
// }
//
// Path: src/main/java/org/terasology/cities/DefaultBlockType.java
// public enum DefaultBlockType implements BlockType {
//
// /**
// * Air
// */
// AIR,
//
// /**
// * Windows
// */
// WINDOW_GLASS,
//
// /**
// * A single-block door element
// */
// SIMPLE_DOOR,
//
// /**
// * A two-folded wing door
// */
// WING_DOOR,
//
// /**
// * Fill material under the surface of a road
// */
// ROAD_FILL,
//
// /**
// * Surface of a road (asphalt)
// */
// ROAD_SURFACE,
//
// /**
// * Empty space in a lot
// */
// LOT_EMPTY,
//
// /**
// * A simple building's floor
// */
// BUILDING_FLOOR,
//
// /**
// * A simple building's foundation
// */
// BUILDING_FOUNDATION,
//
// /**
// * A simple building wall
// */
// BUILDING_WALL,
//
// /**
// * Flat roof
// */
// ROOF_FLAT,
//
// /**
// * Hip roof
// */
// ROOF_HIP,
//
// /**
// * Dome roof
// */
// ROOF_DOME,
//
// /**
// * The roof gable for saddle roofs
// */
// ROOF_GABLE,
//
// /**
// * Saddle roof
// */
// ROOF_SADDLE,
//
// /**
// * Tower stone
// */
// TOWER_WALL,
//
// /**
// * Fence
// */
// FENCE,
//
// /**
// * Fence gate
// */
// FENCE_GATE,
//
// /**
// * Tower staircase
// */
// TOWER_STAIRS,
//
// /**
// * A barrel
// */
// BARREL,
//
// /**
// * A torch
// */
// TORCH,
//
// /**
// * Pillar material
// */
// PILLAR_TOP,
//
// /**
// * Pillar material
// */
// PILLAR_MIDDLE,
//
// /**
// * Pillar material
// */
// PILLAR_BASE,
//
// /**
// * A ladder element
// */
// LADDER
// }
// Path: src/main/java/org/terasology/cities/deco/Pillar.java
import com.google.common.collect.ImmutableList;
import org.joml.Vector3ic;
import org.terasology.cities.BlockType;
import org.terasology.cities.DefaultBlockType;
import org.terasology.engine.math.Side;
import java.util.Collections;
import java.util.List;
/*
* Copyright 2015 MovingBlocks
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.terasology.cities.deco;
public class Pillar extends ColumnDecoration {
/**
* @param basePos the position of the base block
* @param height the total height of the pillar
*/
public Pillar(Vector3ic basePos, int height) {
super(
createList(height),
Collections.nCopies(height, (Side) null),
basePos);
}
private static List<BlockType> createList(int height) {
return ImmutableList.<BlockType>builder() | .add(DefaultBlockType.PILLAR_BASE) |
Terasology/Cities | src/main/java/org/terasology/cities/bldg/BuildingPart.java | // Path: src/main/java/org/terasology/cities/deco/Decoration.java
// public interface Decoration {
// // empty
// }
//
// Path: src/main/java/org/terasology/cities/door/Door.java
// public interface Door {
// // empty marker interface
// }
//
// Path: src/main/java/org/terasology/cities/model/roof/Roof.java
// public interface Roof {
//
//
// }
//
// Path: src/main/java/org/terasology/cities/window/Window.java
// public interface Window {
// // empty
// }
| import org.terasology.cities.deco.Decoration;
import org.terasology.cities.door.Door;
import org.terasology.cities.model.roof.Roof;
import org.terasology.cities.window.Window;
import java.util.Set; | /*
* Copyright 2015 MovingBlocks
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.terasology.cities.bldg;
/**
* Defines a part of a building.
* This is similar to an entire building.
*/
public interface BuildingPart {
Roof getRoof();
int getWallHeight();
int getBaseHeight();
/**
* @return baseHeight + wallHeight;
*/
default int getTopHeight() {
return getBaseHeight() + getWallHeight();
}
| // Path: src/main/java/org/terasology/cities/deco/Decoration.java
// public interface Decoration {
// // empty
// }
//
// Path: src/main/java/org/terasology/cities/door/Door.java
// public interface Door {
// // empty marker interface
// }
//
// Path: src/main/java/org/terasology/cities/model/roof/Roof.java
// public interface Roof {
//
//
// }
//
// Path: src/main/java/org/terasology/cities/window/Window.java
// public interface Window {
// // empty
// }
// Path: src/main/java/org/terasology/cities/bldg/BuildingPart.java
import org.terasology.cities.deco.Decoration;
import org.terasology.cities.door.Door;
import org.terasology.cities.model.roof.Roof;
import org.terasology.cities.window.Window;
import java.util.Set;
/*
* Copyright 2015 MovingBlocks
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.terasology.cities.bldg;
/**
* Defines a part of a building.
* This is similar to an entire building.
*/
public interface BuildingPart {
Roof getRoof();
int getWallHeight();
int getBaseHeight();
/**
* @return baseHeight + wallHeight;
*/
default int getTopHeight() {
return getBaseHeight() + getWallHeight();
}
| Set<Window> getWindows(); |
Terasology/Cities | src/main/java/org/terasology/cities/bldg/BuildingPart.java | // Path: src/main/java/org/terasology/cities/deco/Decoration.java
// public interface Decoration {
// // empty
// }
//
// Path: src/main/java/org/terasology/cities/door/Door.java
// public interface Door {
// // empty marker interface
// }
//
// Path: src/main/java/org/terasology/cities/model/roof/Roof.java
// public interface Roof {
//
//
// }
//
// Path: src/main/java/org/terasology/cities/window/Window.java
// public interface Window {
// // empty
// }
| import org.terasology.cities.deco.Decoration;
import org.terasology.cities.door.Door;
import org.terasology.cities.model.roof.Roof;
import org.terasology.cities.window.Window;
import java.util.Set; | /*
* Copyright 2015 MovingBlocks
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.terasology.cities.bldg;
/**
* Defines a part of a building.
* This is similar to an entire building.
*/
public interface BuildingPart {
Roof getRoof();
int getWallHeight();
int getBaseHeight();
/**
* @return baseHeight + wallHeight;
*/
default int getTopHeight() {
return getBaseHeight() + getWallHeight();
}
Set<Window> getWindows(); | // Path: src/main/java/org/terasology/cities/deco/Decoration.java
// public interface Decoration {
// // empty
// }
//
// Path: src/main/java/org/terasology/cities/door/Door.java
// public interface Door {
// // empty marker interface
// }
//
// Path: src/main/java/org/terasology/cities/model/roof/Roof.java
// public interface Roof {
//
//
// }
//
// Path: src/main/java/org/terasology/cities/window/Window.java
// public interface Window {
// // empty
// }
// Path: src/main/java/org/terasology/cities/bldg/BuildingPart.java
import org.terasology.cities.deco.Decoration;
import org.terasology.cities.door.Door;
import org.terasology.cities.model.roof.Roof;
import org.terasology.cities.window.Window;
import java.util.Set;
/*
* Copyright 2015 MovingBlocks
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.terasology.cities.bldg;
/**
* Defines a part of a building.
* This is similar to an entire building.
*/
public interface BuildingPart {
Roof getRoof();
int getWallHeight();
int getBaseHeight();
/**
* @return baseHeight + wallHeight;
*/
default int getTopHeight() {
return getBaseHeight() + getWallHeight();
}
Set<Window> getWindows(); | Set<Door> getDoors(); |
Terasology/Cities | src/main/java/org/terasology/cities/bldg/BuildingPart.java | // Path: src/main/java/org/terasology/cities/deco/Decoration.java
// public interface Decoration {
// // empty
// }
//
// Path: src/main/java/org/terasology/cities/door/Door.java
// public interface Door {
// // empty marker interface
// }
//
// Path: src/main/java/org/terasology/cities/model/roof/Roof.java
// public interface Roof {
//
//
// }
//
// Path: src/main/java/org/terasology/cities/window/Window.java
// public interface Window {
// // empty
// }
| import org.terasology.cities.deco.Decoration;
import org.terasology.cities.door.Door;
import org.terasology.cities.model.roof.Roof;
import org.terasology.cities.window.Window;
import java.util.Set; | /*
* Copyright 2015 MovingBlocks
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.terasology.cities.bldg;
/**
* Defines a part of a building.
* This is similar to an entire building.
*/
public interface BuildingPart {
Roof getRoof();
int getWallHeight();
int getBaseHeight();
/**
* @return baseHeight + wallHeight;
*/
default int getTopHeight() {
return getBaseHeight() + getWallHeight();
}
Set<Window> getWindows();
Set<Door> getDoors(); | // Path: src/main/java/org/terasology/cities/deco/Decoration.java
// public interface Decoration {
// // empty
// }
//
// Path: src/main/java/org/terasology/cities/door/Door.java
// public interface Door {
// // empty marker interface
// }
//
// Path: src/main/java/org/terasology/cities/model/roof/Roof.java
// public interface Roof {
//
//
// }
//
// Path: src/main/java/org/terasology/cities/window/Window.java
// public interface Window {
// // empty
// }
// Path: src/main/java/org/terasology/cities/bldg/BuildingPart.java
import org.terasology.cities.deco.Decoration;
import org.terasology.cities.door.Door;
import org.terasology.cities.model.roof.Roof;
import org.terasology.cities.window.Window;
import java.util.Set;
/*
* Copyright 2015 MovingBlocks
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.terasology.cities.bldg;
/**
* Defines a part of a building.
* This is similar to an entire building.
*/
public interface BuildingPart {
Roof getRoof();
int getWallHeight();
int getBaseHeight();
/**
* @return baseHeight + wallHeight;
*/
default int getTopHeight() {
return getBaseHeight() + getWallHeight();
}
Set<Window> getWindows();
Set<Door> getDoors(); | Set<Decoration> getDecorations(); |
Terasology/Cities | src/main/java/org/terasology/cities/bldg/RectBuildingPart.java | // Path: src/main/java/org/terasology/cities/bldg/shape/RectangularBase.java
// public interface RectangularBase {
// BlockAreac getShape();
// }
//
// Path: src/main/java/org/terasology/cities/model/roof/Roof.java
// public interface Roof {
//
//
// }
| import org.terasology.cities.bldg.shape.RectangularBase;
import org.terasology.cities.model.roof.Roof;
import org.terasology.engine.world.block.BlockArea;
import org.terasology.engine.world.block.BlockAreac; | /*
* Copyright 2015 MovingBlocks
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.terasology.cities.bldg;
/**
*
*/
public class RectBuildingPart extends AbstractBuildingPart implements RectangularBase {
private final BlockArea layout = new BlockArea(BlockArea.INVALID);
| // Path: src/main/java/org/terasology/cities/bldg/shape/RectangularBase.java
// public interface RectangularBase {
// BlockAreac getShape();
// }
//
// Path: src/main/java/org/terasology/cities/model/roof/Roof.java
// public interface Roof {
//
//
// }
// Path: src/main/java/org/terasology/cities/bldg/RectBuildingPart.java
import org.terasology.cities.bldg.shape.RectangularBase;
import org.terasology.cities.model.roof.Roof;
import org.terasology.engine.world.block.BlockArea;
import org.terasology.engine.world.block.BlockAreac;
/*
* Copyright 2015 MovingBlocks
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.terasology.cities.bldg;
/**
*
*/
public class RectBuildingPart extends AbstractBuildingPart implements RectangularBase {
private final BlockArea layout = new BlockArea(BlockArea.INVALID);
| public RectBuildingPart(BlockAreac layout,Roof roof, int baseHeight, int wallHeight) { |
Terasology/Cities | src/main/java/org/terasology/cities/raster/Pens.java | // Path: src/main/java/org/terasology/cities/BlockType.java
// public interface BlockType {
// // empty marker
// }
| import org.terasology.cities.BlockType;
import org.terasology.commonworld.heightmap.HeightMap; | /*
* Copyright 2015 MovingBlocks
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.terasology.cities.raster;
/**
* A collections of {@Pen} factory methods.
*/
public final class Pens {
private Pens() {
// no instances
}
/**
* @param target the target object
* @param bottomHeight the bottom height (inclusive)
* @param topHeight the top height (exclusive)
* @param type the block type
* @return a new instance
*/ | // Path: src/main/java/org/terasology/cities/BlockType.java
// public interface BlockType {
// // empty marker
// }
// Path: src/main/java/org/terasology/cities/raster/Pens.java
import org.terasology.cities.BlockType;
import org.terasology.commonworld.heightmap.HeightMap;
/*
* Copyright 2015 MovingBlocks
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.terasology.cities.raster;
/**
* A collections of {@Pen} factory methods.
*/
public final class Pens {
private Pens() {
// no instances
}
/**
* @param target the target object
* @param bottomHeight the bottom height (inclusive)
* @param topHeight the top height (exclusive)
* @param type the block type
* @return a new instance
*/ | public static Pen fill(RasterTarget target, int bottomHeight, int topHeight, BlockType type) { |
Terasology/Cities | src/main/java/org/terasology/cities/walls/TownWall.java | // Path: src/main/java/org/terasology/cities/bldg/Tower.java
// public interface Tower extends Building {
// // marker
// }
| import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import org.terasology.cities.bldg.Tower;
import com.google.common.collect.Lists; | /*
* Copyright 2015 MovingBlocks
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.terasology.cities.walls;
/**
* Defines a town wall consisting of {@link Tower}s
* and {@link WallSegment}s.
*/
public class TownWall {
private final List<WallSegment> walls = Lists.newArrayList(); | // Path: src/main/java/org/terasology/cities/bldg/Tower.java
// public interface Tower extends Building {
// // marker
// }
// Path: src/main/java/org/terasology/cities/walls/TownWall.java
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import org.terasology.cities.bldg.Tower;
import com.google.common.collect.Lists;
/*
* Copyright 2015 MovingBlocks
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.terasology.cities.walls;
/**
* Defines a town wall consisting of {@link Tower}s
* and {@link WallSegment}s.
*/
public class TownWall {
private final List<WallSegment> walls = Lists.newArrayList(); | private final List<Tower> towers = new ArrayList<>(); |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.