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 geo shape query filter #319

Merged
merged 1 commit into from
Mar 6, 2023

Conversation

VijayanB
Copy link
Member

@VijayanB VijayanB commented Mar 4, 2023

Description

Added Geo Shape Query Filter to build geo shape query for given shape , relations and label.

Issues Resolved

#213

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
For more information on following Developer Certificate of Origin and signing off your commits, please check here.

@VijayanB VijayanB requested a review from a team March 4, 2023 21:09
@codecov-commenter
Copy link

Codecov Report

Merging #319 (aacdfd9) into main (e3eef6b) will increase coverage by 0.09%.
The diff coverage is n/a.

📣 This organization is not using Codecov’s GitHub App Integration. We recommend you install it so Codecov can continue to function properly for your repositories. Learn more

@@            Coverage Diff             @@
##             main     #319      +/-   ##
==========================================
+ Coverage   90.26%   90.36%   +0.09%     
==========================================
  Files          12       12              
  Lines         298      301       +3     
  Branches       40       40              
==========================================
+ Hits          269      272       +3     
  Misses         19       19              
  Partials       10       10              
Impacted Files Coverage Δ
...plugins/dashboards-maps/public/model/geo/filter.ts 100.00% <0.00%> (ø)

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.


export type GeoShapeFilter = Filter & {
meta: FilterMeta;
geo_shape: any;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we define the type of geo_shape?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Geo shape has variable field name property and fixed string property. How do you recommend create type in that case?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe we can define something like:

type GeoShape = {
  ignore_unmaped: Boolean,
  location: {
    relation: FilterRelations,
    shape: {
      type: 'Polygon',
      coordinates: [
        [
          [number, number],
          [number, number],
          [number, number],
          [number, number],
        ],
      ],
    },
  }
}

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

but location is not fixed. It could be any field name

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In short term I think it's ok to use any, long term we need define the type to make it safer usage

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We might can use generic type for it?

type Coordinate = [number, number];

type Polygon = {
  type: 'Polygon';
  coordinates: Coordinate[][];
};

type Geometry = Polygon;

type Location<F extends string> = {
  [K in F]: {
    relation: 'INTERSECTS';
    shape: Geometry;
  };
};

type GeoShape<F extends string> = {
  ignore_unmaped: true;
} & Location<F> & Geometry;

@VijayanB VijayanB requested a review from junqiu-lei March 6, 2023 17:54
@VijayanB VijayanB force-pushed the add-geoshape-filter branch 2 times, most recently from b6a8739 to d0f9d00 Compare March 6, 2023 18:51
@VijayanB VijayanB self-assigned this Mar 6, 2023
Signed-off-by: Vijayan Balasubramanian <balasvij@amazon.com>
@VijayanB VijayanB merged commit 16fca69 into opensearch-project:main Mar 6, 2023
opensearch-trigger-bot bot pushed a commit that referenced this pull request Mar 6, 2023
Added Geo Shape Query Filter to build geo shape query for given shape , relations and label.

Signed-off-by: Vijayan Balasubramanian <balasvij@amazon.com>
(cherry picked from commit 16fca69)
junqiu-lei pushed a commit that referenced this pull request Mar 6, 2023
Added Geo Shape Query Filter to build geo shape query for given shape , relations and label.

Signed-off-by: Vijayan Balasubramanian <balasvij@amazon.com>
(cherry picked from commit 16fca69)

Co-authored-by: Vijayan Balasubramanian <vijayan.balasubramanian@gmail.com>
VijayanB pushed a commit to VijayanB/dashboards-maps that referenced this pull request Mar 20, 2023
…ct#325)

Added Geo Shape Query Filter to build geo shape query for given shape , relations and label.

Signed-off-by: Vijayan Balasubramanian <balasvij@amazon.com>
(cherry picked from commit 16fca69)

Co-authored-by: Vijayan Balasubramanian <vijayan.balasubramanian@gmail.com>
(cherry picked from commit 4149520)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants