-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #8 from SWM-M3PRO/feature/M3-140-individualPixelRe…
…impl M3-140 픽셀 개인전 정보를 가져오는 API 다시 만들기
- Loading branch information
Showing
6 changed files
with
137 additions
and
20 deletions.
There are no files selected for viewing
16 changes: 16 additions & 0 deletions
16
src/main/java/com/m3pro/groundflip/config/GeometryConfig.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,16 @@ | ||
package com.m3pro.groundflip.config; | ||
|
||
import org.locationtech.jts.geom.GeometryFactory; | ||
import org.locationtech.jts.geom.PrecisionModel; | ||
import org.springframework.context.annotation.Bean; | ||
import org.springframework.context.annotation.Configuration; | ||
|
||
@Configuration | ||
public class GeometryConfig { | ||
private static final int WGS84_SRID = 4326; | ||
|
||
@Bean | ||
public GeometryFactory geometryFactory() { | ||
return new GeometryFactory(new PrecisionModel(), WGS84_SRID); | ||
} | ||
} |
21 changes: 21 additions & 0 deletions
21
src/main/java/com/m3pro/groundflip/config/GeometryConverter.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,21 @@ | ||
package com.m3pro.groundflip.config; | ||
|
||
import org.geolatte.geom.G2D; | ||
import org.geolatte.geom.Point; | ||
import org.locationtech.jts.geom.Coordinate; | ||
import org.locationtech.jts.geom.GeometryFactory; | ||
import org.locationtech.jts.geom.PrecisionModel; | ||
import org.springframework.stereotype.Component; | ||
|
||
@Component | ||
public class GeometryConverter { | ||
private static final GeometryFactory geometryFactory = new GeometryFactory(new PrecisionModel(), 4326); | ||
|
||
public static org.locationtech.jts.geom.Point convertGeomToJts(Object geolattePoint) { | ||
Point<G2D> point = (Point<G2D>)geolattePoint; | ||
|
||
G2D position = point.getPosition(); | ||
Coordinate coordinate = new Coordinate(position.getLon(), position.getLat()); | ||
return geometryFactory.createPoint(coordinate); | ||
} | ||
} |
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
39 changes: 33 additions & 6 deletions
39
src/main/java/com/m3pro/groundflip/domain/dto/pixel/IndividualPixelResponse.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 |
---|---|---|
@@ -1,22 +1,49 @@ | ||
package com.m3pro.groundflip.domain.dto.pixel; | ||
|
||
import com.m3pro.groundflip.domain.entity.Pixel; | ||
import org.locationtech.jts.geom.Point; | ||
|
||
import com.m3pro.groundflip.config.GeometryConverter; | ||
|
||
import io.swagger.v3.oas.annotations.media.Schema; | ||
import lombok.AllArgsConstructor; | ||
import lombok.Builder; | ||
import lombok.Data; | ||
import lombok.NoArgsConstructor; | ||
|
||
@AllArgsConstructor | ||
@NoArgsConstructor | ||
@Data | ||
@Builder | ||
@Schema(title = "개인전 픽셀 정보") | ||
public class IndividualPixelResponse { | ||
@Schema(description = "픽셀 ID", example = "78611") | ||
private long pixelId; | ||
|
||
@Schema(description = "픽셀 좌측 상단 위도", example = "37.503717") | ||
private double latitude; | ||
|
||
@Schema(description = "픽셀 좌측 상단 경도", example = "127.044317") | ||
private double longitude; | ||
private double x; | ||
private double y; | ||
|
||
public static IndividualPixelResponse from(Pixel pixel) { | ||
return new IndividualPixelResponse(pixel.getCoordinate().getX(), pixel.getCoordinate().getY(), pixel.getX(), | ||
pixel.getY()); | ||
@Schema(description = "소유주의 ID", example = "3") | ||
private long userId; | ||
|
||
@Schema(description = "픽셀 세로 상대 좌표", example = "224") | ||
private long x; | ||
|
||
@Schema(description = "픽셀 가로 상대 좌표", example = "210") | ||
private long y; | ||
|
||
public static IndividualPixelResponse from(Object[] queryResult) { | ||
Point coordinate = GeometryConverter.convertGeomToJts(queryResult[1]); | ||
|
||
return IndividualPixelResponse.builder() | ||
.pixelId((long)queryResult[0]) | ||
.latitude(coordinate.getY()) | ||
.longitude(coordinate.getX()) | ||
.userId((long)queryResult[2]) | ||
.x((long)queryResult[3]) | ||
.y((long)queryResult[4]) | ||
.build(); | ||
} | ||
} |
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