-
Notifications
You must be signed in to change notification settings - Fork 63
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ses, Add bbox to Feature and FeatureCollection.
- Loading branch information
1 parent
c83e92d
commit 2ebfee3
Showing
8 changed files
with
109 additions
and
7 deletions.
There are no files selected for viewing
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
30 changes: 30 additions & 0 deletions
30
json/src/main/java/org/geolatte/geom/json/BoxSerializer.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,30 @@ | ||
package org.geolatte.geom.json; | ||
|
||
import com.fasterxml.jackson.core.JsonGenerator; | ||
import com.fasterxml.jackson.databind.JsonSerializer; | ||
import com.fasterxml.jackson.databind.SerializerProvider; | ||
import org.geolatte.geom.Box; | ||
import org.geolatte.geom.Position; | ||
|
||
import java.io.IOException; | ||
import java.util.Arrays; | ||
|
||
public class BoxSerializer<P extends Position> extends JsonSerializer<Box<P>> { | ||
|
||
@Override | ||
public void serialize(Box<P> box, JsonGenerator gen, SerializerProvider serializers) throws IOException { | ||
final double[] bbox = concat(box.lowerLeft().toArray(null), box.upperRight().toArray(null)); | ||
gen.writeArray(bbox, 0, bbox.length); | ||
} | ||
|
||
@Override | ||
public boolean isEmpty(SerializerProvider provider, Box<P> box) { | ||
return box == null || box.isEmpty(); | ||
} | ||
|
||
private double[] concat(double[] pos1, double[] pos2) { | ||
double[] result = Arrays.copyOf(pos1, pos1.length + pos2.length); | ||
System.arraycopy(pos2, 0, result, pos1.length, pos2.length); | ||
return result; | ||
} | ||
} |
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