Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
jievince committed Nov 10, 2021
1 parent b1173b0 commit 9615a5e
Showing 1 changed file with 15 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,11 @@ import com.vesoft.nebula.exchange.utils.{HDFSUtils, NebulaUtils}
import com.vesoft.nebula.meta.PropertyType
import org.apache.spark.sql.Row
import org.apache.spark.sql.types.{IntegerType, LongType, StringType}

import org.locationtech.jts.io.ByteOrderValues;
import org.locationtech.jts.geom.Geometry;
import org.locationtech.jts.io.WKBWriter;

import scala.collection.JavaConverters._
import scala.collection.mutable.ListBuffer
/**
* processor is a converter.
* It is responsible for converting the dataframe row data into Nebula Graph's vertex or edge,
Expand Down Expand Up @@ -160,9 +162,7 @@ trait Processor extends Serializable {
}
case PropertyType.GEOGRAPHY => {
val wkt = row.get(index).toString
org.locationtech.jts.geom.Geometry jtsGeom = new org.locationtech.jts.io
.WKTReader(2, ByteOrderValues.LITTLE_ENDIAN)
.read(wkt);
val jtsGeom = new org.locationtech.jts.io.WKTReader().read(wkt);
convertJTSGeometryToGeography(jtsGeom)
}
}
Expand All @@ -188,27 +188,27 @@ trait Processor extends Serializable {
Geography.ptVal(new Point(new Coordinate(jtsCoord.x, jtsCoord.y)))
}
case Geometry.TYPENAME_LINESTRING => {
val jtsCoordList = jtsGeom.getCoordinates().asScala
val coordList = scala.collection.mutable.ListBuffer.empty[Coordinate]
for (var jtsCoord <- jtsCoordList) {
coordList += jtsCoord
val jtsCoordList = jtsGeom.getCoordinates()
var coordList = new ListBuffer[Coordinate]()
for (jtsCoord <- jtsCoordList) {
coordList += new Coordinate(jtsCoord.x, jtsCorod.y)
}
Geography.lsVal(new LineString(coordList.asJava))
}
case Geometry.TYPENAME_POLYGON => {
val coordListList = ListBuffer[ListBuffer[Coordinate]]
var coordListList = new ListBuffer[ListBuffer[Coordinate]]()
val jtsShell = jtsGeom.getExteriorRing()
val coordList = ListBuffer[Coordinate]
for (var jtsCoord <- jtsShell.getCoordinates()) {
var coordList = ListBuffer[Coordinate]
for (jtsCoord <- jtsShell.getCoordinates()) {
coordList += new Coordinate(jtsCoord.x, jtsCoord.y)
}
coordListList += coordList

val jtsHolesNum = jtsGeom.getNumInteriorRing()
for (var i <- 0 to jtsHolesNum) {
val coordList = ListBuffer[Coordinate]
for (i <- 0 until jtsHolesNum) {
var coordList = new ListBuffer[Coordinate]()
val jtsHole = jtsGeom.getInteriorRingN(i)
for (var jtsCoord <- jtsHole.geteCoordinates()) {
for (jtsCoord <- jtsHole.geteCoordinates()) {
coordList += new Coordinate(jtsCoord.x, jtsCoord.y)
}
coordListList += coordList
Expand Down

0 comments on commit 9615a5e

Please sign in to comment.