Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add function to compute centroid #167

Closed
mbasmanova opened this issue Apr 5, 2018 · 5 comments
Closed

Add function to compute centroid #167

mbasmanova opened this issue Apr 5, 2018 · 5 comments

Comments

@mbasmanova
Copy link
Contributor

I cannot find an API to compute centroid of a geometry and I noticed that ST_Centroid function in spatial-framework-for-hadoop returns centroid of the bounding box and not of the geometry itself.

https://github.com/Esri/spatial-framework-for-hadoop/wiki/UDF-Accessors#st_centroid

I implemented ST_Centroid function in Presto using formulas from https://en.wikipedia.org/wiki/Centroid and now wondering if it makes sense to add the same to this library.

https://github.com/mbasmanova/presto/blob/master/presto-geospatial/src/main/java/com/facebook/presto/plugin/geospatial/GeoFunctions.java#L160

@randallwhitman
Copy link
Contributor

@alocke @stolstov If a centroid function were contributed to Geometry, I'd be eager to utilize it for ST_Centroid in Spatial Framework for Hadoop.

@mbasmanova
Copy link
Contributor Author

@stolstov Sergey, how would you feel about adding centroid function to the library?

@stolstov
Copy link
Member

stolstov commented Apr 9, 2018

@mbasmanova Would like to contribute?

The following signature would be preferable:

public abstract class OperatorCentroid2D extends Operator {
	@Override
	public Type getType() {
		return Type.Centroid;
	}

	public abstract Point2D execute(Geometry geometry,
			ProgressTracker progressTracker);

	public static OperatorCentroid2D local()
}

@mbasmanova
Copy link
Contributor Author

@stolstov Sure, I'd be happy to contribute an implementation of centroid. Thanks for the tip about how to get started. I put something together at #169 . Would you take a look?

@stolstov stolstov added this to the 2.1.1 milestone Apr 10, 2018
@randallwhitman randallwhitman modified the milestones: 2.1.1, 2.2.0 May 17, 2018
@alocke alocke self-assigned this Sep 10, 2018
@alocke
Copy link
Member

alocke commented Sep 10, 2018

Verification

  • TestCentroid
  • TestOGCCentroid

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants