Skip to content

Commit 707595d

Browse files
committed
Add WKT implementation of Format[Projection]
1 parent c5a1796 commit 707595d

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

geoscript/src/main/scala/projection/Projection.scala

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,25 @@ package object projection {
4545
}
4646

4747
package projection {
48+
import org.geoscript.serialize._
49+
4850
class RichProjection(p: Projection) {
4951
def id = CRS.lookupIdentifier(p, true)
5052
}
53+
54+
object WKT extends Format[Projection] {
55+
def readFrom(in: java.io.Reader): Projection = {
56+
val accum = new StringBuilder()
57+
val buff = Array.ofDim[Char](4096)
58+
var len = 0
59+
while ({ len = in.read(buff) ; len >= 0 }) {
60+
accum.appendAll(buff, 0, len)
61+
}
62+
CRS.parseWKT(accum.toString)
63+
}
64+
65+
def writeTo(out: java.io.Writer, p: Projection): Unit = {
66+
out.write(p.toWKT)
67+
}
68+
}
5169
}

0 commit comments

Comments
 (0)