Skip to content

Commit

Permalink
merge conflicts (#46504)
Browse files Browse the repository at this point in the history
  • Loading branch information
nreese committed Sep 26, 2019
1 parent 14e837c commit 41fa2ef
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 32 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export class FeatureGeometryFilterForm extends Component {

_createFilter = ({ geometryLabel, indexPatternId, geoFieldName, geoFieldType, relation }) => {
const filter = createSpatialFilterWithGeometry({
geometry: this.props.feature.geometry,
geometry: this.props.geometry,
geometryLabel,
indexPatternId,
geoFieldName,
Expand Down Expand Up @@ -69,10 +69,10 @@ export class FeatureGeometryFilterForm extends Component {
defaultMessage: 'Create filter'
})}
geoFields={this.props.geoFields}
intitialGeometryLabel={this.props.feature.geometry.type.toLowerCase()}
intitialGeometryLabel={this.props.geometry.type.toLowerCase()}
onSubmit={this._createFilter}
isFilterGeometryClosed={this.props.feature.geometry.type !== GEO_JSON_TYPE.LINE_STRING
&& this.props.feature.geometry.type !== GEO_JSON_TYPE.MULTI_LINE_STRING}
isFilterGeometryClosed={this.props.geometry.type !== GEO_JSON_TYPE.LINE_STRING
&& this.props.geometry.type !== GEO_JSON_TYPE.MULTI_LINE_STRING}
/>
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ export class FeatureTooltip extends React.Component {
);
}

_renderActions(feature, geoFields) {
_renderActions(geoFields) {
if (!this.props.isLocked || geoFields.length === 0) {
return null;
}
Expand Down Expand Up @@ -270,22 +270,22 @@ export class FeatureTooltip extends React.Component {
});
}

_filterGeoFields(feature) {
if (!feature) {
_filterGeoFields(featureGeometry) {
if (!featureGeometry) {
return [];
}

// line geometry can only create filters for geo_shape fields.
if (feature.geometry.type === GEO_JSON_TYPE.LINE_STRING
|| feature.geometry.type === GEO_JSON_TYPE.MULTI_LINE_STRING) {
if (featureGeometry.type === GEO_JSON_TYPE.LINE_STRING
|| featureGeometry.type === GEO_JSON_TYPE.MULTI_LINE_STRING) {
return this.props.geoFields.filter(({ geoFieldType }) => {
return geoFieldType === ES_GEO_FIELD_TYPE.GEO_SHAPE;
});
}

// TODO support geo distance filters for points
if (feature.geometry.type === GEO_JSON_TYPE.POINT
|| feature.geometry.type === GEO_JSON_TYPE.MULTI_POINT) {
if (featureGeometry.type === GEO_JSON_TYPE.POINT
|| featureGeometry.type === GEO_JSON_TYPE.MULTI_POINT) {
return [];
}

Expand Down Expand Up @@ -342,14 +342,18 @@ export class FeatureTooltip extends React.Component {
render() {
const filteredFeatures = this._filterFeatures();
const currentFeature = filteredFeatures[this.state.pageNumber];
const filteredGeoFields = this._filterGeoFields(currentFeature);
const currentFeatureGeometry = this.props.loadFeatureGeometry({
layerId: currentFeature.layerId,
featureId: currentFeature.id
});
const filteredGeoFields = this._filterGeoFields(currentFeatureGeometry);

if (this.state.view === VIEWS.GEOMETRY_FILTER_VIEW) {
if (this.state.view === VIEWS.GEOMETRY_FILTER_VIEW && currentFeatureGeometry) {
return (
<FeatureGeometryFilterForm
onClose={this._onCloseTooltip}
showPropertiesView={this._showPropertiesView}
feature={currentFeature}
geometry={currentFeatureGeometry}
geoFields={filteredGeoFields}
addFilters={this.props.addFilters}
reevaluateTooltipPosition={this.props.reevaluateTooltipPosition}
Expand All @@ -361,7 +365,7 @@ export class FeatureTooltip extends React.Component {
<Fragment>
{this._renderHeader()}
{this._renderProperties(currentFeature)}
{this._renderActions(currentFeature, filteredGeoFields)}
{this._renderActions(filteredGeoFields)}
{this._renderFooter(filteredFeatures)}
</Fragment>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,42 +21,32 @@ const MULTI_FEATURE_MULTI_LAYER = [
{
id: 'feature1',
layerId: 'layer1',
geometry: {
type: 'Point',
coordinates: [102.0, 0.5]
}
},
{
id: 'feature2',
layerId: 'layer1',
geometry: {
type: 'Point',
coordinates: [102.0, 0.5]
}
},
{
id: 'feature1',
layerId: 'layer2',
geometry: {
type: 'Point',
coordinates: [102.0, 0.5]
}
}
];

const SINGLE_FEATURE = [
{
id: 'feature1',
layerId: 'layer1',
geometry: {
type: 'Point',
coordinates: [102.0, 0.5]
}
}
];

const defaultProps = {
loadFeatureProperties: () => { return []; },
loadFeatureGeometry: () => {
return {
type: 'Point',
coordinates: [102.0, 0.5]
};
},
findLayerById: (id) => {
return new MockLayer(id);
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,6 @@ export class MBMapContainer extends React.Component {
uniqueFeatures.push({
id: featureId,
layerId: layerId,
geometry: mbFeature.geometry,
});
}
}
Expand Down Expand Up @@ -497,6 +496,7 @@ export class MBMapContainer extends React.Component {
addFilters={this.props.addFilters}
geoFields={this.props.geoFields}
reevaluateTooltipPosition={this._reevaluateTooltipPosition}
loadFeatureGeometry={this._loadFeatureGeometry}
/>
</I18nProvider>
), this._tooltipContainer);
Expand All @@ -506,6 +506,21 @@ export class MBMapContainer extends React.Component {
.addTo(this._mbMap);
}

// Must load original geometry instead of using geometry from mapbox feature.
// Mapbox feature geometry is from vector tile and is not the same as the original geometry.
_loadFeatureGeometry = ({ layerId, featureId }) => {
const tooltipLayer = this._findLayerById(layerId);
if (!tooltipLayer) {
return null;
}
const targetFeature = tooltipLayer.getFeatureById(featureId);
if (!targetFeature) {
return null;
}

return targetFeature.geometry;
};

_loadFeatureProperties = async ({ layerId, featureId }) => {
const tooltipLayer = this._findLayerById(layerId);
if (!tooltipLayer) {
Expand Down

0 comments on commit 41fa2ef

Please sign in to comment.