-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added affine transformation options to import and export
- Loading branch information
1 parent
71d2535
commit 552e7f4
Showing
8 changed files
with
159 additions
and
12 deletions.
There are no files selected for viewing
50 changes: 50 additions & 0 deletions
50
citydb-model/src/main/java/org/citydb/model/encoding/Matrix3x4Reader.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
/* | ||
* citydb-tool - Command-line tool for the 3D City Database | ||
* https://www.3dcitydb.org/ | ||
* | ||
* Copyright 2022-2025 | ||
* virtualcitysystems GmbH, Germany | ||
* https://vc.systems/ | ||
* | ||
* 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.citydb.model.encoding; | ||
|
||
import com.alibaba.fastjson2.JSONReader; | ||
import com.alibaba.fastjson2.reader.ObjectReader; | ||
import org.citydb.model.common.Matrix3x4; | ||
|
||
import java.lang.reflect.Type; | ||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
public class Matrix3x4Reader implements ObjectReader<Matrix3x4> { | ||
@Override | ||
public Matrix3x4 readObject(JSONReader jsonReader, Type type, Object o, long l) { | ||
if (jsonReader.isArray()) { | ||
List<Double> values = new ArrayList<>(); | ||
for (Object value : jsonReader.readArray()) { | ||
if (value instanceof Number number) { | ||
values.add(number.doubleValue()); | ||
} | ||
} | ||
|
||
if (values.size() > 11) { | ||
return Matrix3x4.ofRowMajor(values); | ||
} | ||
} | ||
|
||
return null; | ||
} | ||
} |
48 changes: 48 additions & 0 deletions
48
citydb-model/src/main/java/org/citydb/model/encoding/Matrix3x4Writer.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
/* | ||
* citydb-tool - Command-line tool for the 3D City Database | ||
* https://www.3dcitydb.org/ | ||
* | ||
* Copyright 2022-2025 | ||
* virtualcitysystems GmbH, Germany | ||
* https://vc.systems/ | ||
* | ||
* 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.citydb.model.encoding; | ||
|
||
import com.alibaba.fastjson2.JSONWriter; | ||
import com.alibaba.fastjson2.writer.ObjectWriter; | ||
import org.citydb.model.common.Matrix3x4; | ||
|
||
import java.lang.reflect.Type; | ||
import java.util.List; | ||
|
||
public class Matrix3x4Writer implements ObjectWriter<Matrix3x4> { | ||
@Override | ||
public void write(JSONWriter jsonWriter, Object o, Object o1, Type type, long l) { | ||
if (o instanceof Matrix3x4 matrix) { | ||
jsonWriter.startArray(); | ||
List<Double> values = matrix.toRowMajor(); | ||
for (int i = 0; i < values.size(); i++) { | ||
if (i != 0) { | ||
jsonWriter.writeComma(); | ||
} | ||
jsonWriter.writeDouble(values.get(i)); | ||
} | ||
jsonWriter.endArray(); | ||
} else { | ||
jsonWriter.writeNull(); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters