use of com.revolsys.geometry.model.GeometryFactory in project com.revolsys.open by revolsys.
the class ScaledIntegerPointCloudGeometryWriter method initialize.
private void initialize() throws IOException {
if (!this.initialized) {
this.initialized = true;
final ChannelWriter writer = this.resource.newChannelWriter(this.byteBuffer);
this.writer = writer;
final GeometryFactory geometryFactory = this.geometryFactory;
// File
writer.putBytes(ScaledIntegerPointCloud.FILE_TYPE_HEADER_BYTES);
// type
// version
writer.putShort(ScaledIntegerPointCloud.VERSION);
// Flags
writer.putShort((short) 0);
geometryFactory.writeOffsetScaled3d(writer);
}
}
use of com.revolsys.geometry.model.GeometryFactory in project com.revolsys.open by revolsys.
the class ScaledIntegerPointCloudGeometryWriter method write.
public void write(final double x, final double y, final double z) {
try {
initialize();
final ChannelWriter writer = this.writer;
final GeometryFactory geometryFactory = this.geometryFactory;
final int xInt = geometryFactory.toIntX(x);
writer.putInt(xInt);
final int yInt = geometryFactory.toIntY(y);
writer.putInt(yInt);
final int zInt = geometryFactory.toIntZ(z);
writer.putInt(zInt);
} catch (final IOException e) {
throw Exceptions.wrap(e);
}
}
use of com.revolsys.geometry.model.GeometryFactory in project com.revolsys.open by revolsys.
the class PointConverter method read.
@Override
public Object read(final OsnIterator iterator) {
final Map<String, Object> values = new TreeMap<>();
values.put("type", this.geometryClass);
Point point = null;
String fieldName = iterator.nextFieldName();
while (fieldName != null) {
if (fieldName.equals("coords")) {
final String coordTypeName = iterator.nextObjectName();
if (coordTypeName.equals("/Coord3D")) {
final double x = iterator.nextDoubleAttribute("c1");
final double y = iterator.nextDoubleAttribute("c2");
double z = iterator.nextDoubleAttribute("c3");
if (z == 2147483648.0) {
z = 0;
}
final GeometryFactory geometryFactory = this.geometryFactory.convertAxisCount(3);
point = newPoint(geometryFactory, x, y, z);
} else if (coordTypeName.equals("/Coord2D")) {
final double x = iterator.nextDoubleAttribute("c1");
final double y = iterator.nextDoubleAttribute("c2");
final GeometryFactory geometryFactory = this.geometryFactory.convertAxisCount(3);
point = newPoint(geometryFactory, x, y);
} else {
iterator.throwParseError("Expecting Coord2D or Coord3D");
}
iterator.nextEndObject();
} else {
readAttribute(iterator, fieldName, values);
}
fieldName = iterator.nextFieldName();
}
Property.set(point, values);
return point;
}
use of com.revolsys.geometry.model.GeometryFactory in project com.revolsys.open by revolsys.
the class RecordDefinitionImpl method addField.
public synchronized void addField(final FieldDefinition field) {
final int index = this.fieldNames.size();
final String name = field.getName();
String lowerName;
if (name == null) {
lowerName = null;
} else {
lowerName = name.toLowerCase();
}
this.internalFieldNames.add(name);
this.fieldNames = Lists.unmodifiable(this.internalFieldNames);
this.fieldNamesSet = Sets.unmodifiableLinked(this.internalFieldNames);
this.internalFields.add(field);
this.fields = Lists.unmodifiable(this.internalFields);
this.fieldMap.put(lowerName, field);
this.fieldIdMap.put(lowerName, this.fieldIdMap.size());
final DataType dataType = field.getDataType();
if (dataType == null) {
Logs.debug(this, field.toString());
} else {
final Class<?> dataClass = dataType.getJavaClass();
if (Geometry.class.isAssignableFrom(dataClass)) {
this.geometryFieldDefinitionIndexes.add(index);
this.geometryFieldDefinitionNames.add(name);
if (this.geometryFieldDefinitionIndex == -1) {
this.geometryFieldDefinitionIndex = index;
final GeometryFactory geometryFactory = field.getProperty(FieldProperties.GEOMETRY_FACTORY);
if (geometryFactory == null && this.geometryFactory != null) {
field.setProperty(FieldProperties.GEOMETRY_FACTORY, this.geometryFactory);
}
}
}
}
field.setIndex(index);
field.setRecordDefinition(this);
final CodeTable codeTable = field.getCodeTable();
addFieldCodeTable(name, codeTable);
}
use of com.revolsys.geometry.model.GeometryFactory in project com.revolsys.open by revolsys.
the class RecordDefinitionImpl method toMap.
@Override
public MapEx toMap() {
final MapEx map = new LinkedHashMapEx();
addTypeToMap(map, "recordDefinition");
final String path = getPath();
map.put("path", path);
final ClockDirection polygonRingDirection = getPolygonRingDirection();
addToMap(map, "polygonRingDirection", polygonRingDirection, null);
final GeometryFactory geometryFactory = getGeometryFactory();
addToMap(map, "geometryFactory", geometryFactory, null);
final List<FieldDefinition> fields = getFields();
addToMap(map, "fields", fields);
return map;
}
Aggregations