Skip to content

Commit

Permalink
Create AysLocationUtil
Browse files Browse the repository at this point in the history
  • Loading branch information
Rapter1990 committed Aug 21, 2023
1 parent 6b68522 commit 05c2cf0
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions src/main/java/com/ays/common/util/AysLocationUtil.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package com.ays.common.util;

import lombok.experimental.UtilityClass;
import org.locationtech.jts.geom.*;
import org.locationtech.jts.geom.impl.CoordinateArraySequence;

/**
* Utility class for handling location-related operations.
* Provides methods to generate geometric points based on latitude and longitude coordinates.
*/
@UtilityClass
public class AysLocationUtil {

/**
* Generates a Point object representing a location based on the provided latitude and longitude coordinates.
*
* @param latitude The latitude coordinate of the location.
* @param longitude The longitude coordinate of the location.
* @return A Point object representing the location.
*/
public static Point generatePoint(final Double latitude, final Double longitude) {
final Coordinate[] coordinates = new Coordinate[]{new Coordinate(latitude, longitude)};
final CoordinateSequence coordinateSequence = new CoordinateArraySequence(coordinates);
final PrecisionModel precisionModel = new PrecisionModel(PrecisionModel.FLOATING);
return new GeometryFactory(precisionModel, 4326).createPoint(coordinateSequence);
}

}

0 comments on commit 05c2cf0

Please sign in to comment.