Skip to content

Commit

Permalink
Revert "set BatchAddressSearch as landing page"
Browse files Browse the repository at this point in the history
  • Loading branch information
cswbrian authored Jan 6, 2019
1 parent 73f69f6 commit d62bfc3
Show file tree
Hide file tree
Showing 20 changed files with 529 additions and 758 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
Expand Down
2 changes: 1 addition & 1 deletion accuracy_test/run_test.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const addressParser = require('./../web/src/lib/ogcio-parser');
const addressParser = require('./../web/src/lib/address-parser');
const Promise = require('bluebird');
const request = Promise.promisifyAll(require('request'));

Expand Down
25 changes: 0 additions & 25 deletions package-lock.json

This file was deleted.

3 changes: 2 additions & 1 deletion web/src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
<v-toolbar-title>香港地址解析器 Hong Kong Address Parser (Beta - Release 0.3)</v-toolbar-title>
<v-spacer></v-spacer>
<v-toolbar-items>
<v-btn flat to="/">解析地址</v-btn>
<v-btn flat to="/">單次處理</v-btn>
<v-btn flat to="/batch">大量處理</v-btn>
<v-btn flat href="https://goo.gl/forms/r6bdJHG228IZTgIZ2" target="_blank">反映意見</v-btn>
</v-toolbar-items>
</v-toolbar>
Expand Down
Binary file removed web/src/assets/pin-selected.png
Binary file not shown.
4 changes: 2 additions & 2 deletions web/src/components/SearchFilter.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<template>
<v-flex>
<v-container>
<v-layout row wrap>
<v-flex
:xs3="xs3"
Expand All @@ -13,7 +13,7 @@
></v-checkbox>
</v-flex>
</v-layout>
</v-flex>
</v-container>
</template>

<script>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<template>
<v-expansion-panel focusable expand :value="expanded">
<v-expansion-panel-content :disabled="disableContent">

<div slot="header">
<div v-if="isBestMatch" class="btn-container">
<ButtonTick :enabled="!commented" :onClick="onTickClicked"/>
Expand All @@ -12,13 +13,17 @@
small
>{{ `Rank ${rank + 1}` }} {{ isBestMatch? ' - Best Match!' : ''}}
</v-chip>

<h2>
<p>{{ result.fullAddress('chi') }}</p>
<p>{{ result.fullAddress('eng') }}</p>
<p>{{ fullChineseAddressFromResult(result.chi) }}</p>
<p>{{ fullEnglishAddressFromResult(result.eng) }}</p>
</h2>
<span
class="text-xs-right grey--text"
>{{ result.coordinate().lat + ", " + result.coordinate().lng }}</span>
>{{ result.geo[0].Latitude + ", " + result.geo[0].Longitude }}</span>



</div>
<v-card class="ma-4 pa-3">
<v-list dense subheader>
Expand All @@ -43,20 +48,22 @@
</v-list-tile>
<v-divider></v-divider>
</v-list>

<v-list
dense
subheader
v-for="key in filteredKeys"
:key="key"
:class="`match_level_${getConfidentLevel(key)}`"
>
<v-list-tile>
<v-list-tile-content>
<p>{{ result.componentLabelForKey(key, 'eng') }}</p>
<p>{{ result.componentLabelForKey(key, 'chi') }}</p>
<p>{{ textForKey(key, 'eng') }}</p>
<p>{{ textForKey(key, 'chi') }}</p>
</v-list-tile-content>
<v-list-tile-content class="align-end">
<p>{{ result.componentValueForKey(key, 'eng') }}</p>
<p>{{ result.componentValueForKey(key, 'chi') }}</p>
<p>{{ textForValue(result, key, 'eng') }}</p>
<p>{{ textForValue(result, key, 'chi') }}</p>
</v-list-tile-content>
</v-list-tile>
<v-divider></v-divider>
Expand All @@ -67,8 +74,8 @@
</template>

<script>
import Address from './../lib/models/address';
import dclookup from "./../utils/dclookup";
import dclookup from "./../utils/dclookup.js";
import ogcioHelper from "./../utils/ogcio-helper.js";
import ButtonTick from './ButtonTick';
import ButtonCross from './ButtonCross';
import {
Expand All @@ -81,15 +88,21 @@ export default {
props: {
searchAddress: String,
rank: Number,
result: Address,
result: {
status: Object,
geo: Array,
chi: Object,
eng: Object,
matches: Array
},
filterOptions: Array
},
data: () => ({
commented: false,
disableContent: false,
filteredKeys: [],
localFilterOptions: [],
expanded: [true] // set the default value by the rank. first object should be expanded
expanded: [false] // set the default value by the rank. first object should be expanded
}),
mounted: function() {
this.localFilterOptions = this.filterOptions;
Expand All @@ -100,13 +113,13 @@ export default {
this.filteredKeys = this.getFilteredKeys();
this.$forceUpdate();
});
//this.expanded = [this.isBestMatch];
this.expanded = [this.isBestMatch];
},
computed: {
district: function() {
return dclookup.dcNameFromCoordinates(
this.result.coordinate().lat,
this.result.coordinate().lng
this.result.geo[0].Latitude,
this.result.geo[0].Longitude
);
},
isBestMatch: function () {
Expand All @@ -118,9 +131,25 @@ export default {
e.stopPropagation();
console.log('tick');
},
textForKey: ogcioHelper.textForKey,
textForValue: ogcioHelper.textForValue,
fullChineseAddressFromResult: ogcioHelper.fullChineseAddressFromResult,
fullEnglishAddressFromResult: ogcioHelper.fullEnglishAddressFromResult,
// To a confident level of 0-4
getConfidentLevel: function(key) {
return Math.min(
4,
(this.result.matches
.filter(match => match.matchedKey === key)
.map(match => match.confident)
.reduce((p, c) => c, 0) *
5) |
0
);
},
getFilteredKeys: function() {
return (this.filteredKeys = this.localFilterOptions
.filter(opt => opt.enabled && this.result.componentLabelForKey(opt.key, 'chi') !== '')
.filter(opt => opt.enabled && this.result.chi[opt.key] !== undefined)
.map(opt => opt.key));
},
disableExpansionPanelContent: function() {
Expand All @@ -142,6 +171,23 @@ export default {
</script>

<style>
.match_level_1 {
color: rgb(255, 144, 144) !important;
font-weight: bolder;
}
.match_level_2 {
color: rgb(231, 141, 141) !important;
}
.match_level_3 {
color: rgb(248, 87, 87) !important;
}
.match_level_4 {
color: red !important;
font-weight: bolder;
}
.align-end {
text-align: right;
Expand Down
121 changes: 48 additions & 73 deletions web/src/components/VueLayerMap.vue
Original file line number Diff line number Diff line change
@@ -1,35 +1,18 @@
<template>
<vl-map :load-tiles-while-animating="true" :load-tiles-while-interacting="true" data-projection="EPSG:4326">
<vl-view :zoom.sync="zoom" :center.sync="center" :rotation.sync="rotation"></vl-view>

<vl-layer-tile id="osm">
<vl-source-osm></vl-source-osm>
</vl-layer-tile>

<!-- interactions -->
<vl-interaction-select :features.sync="selectedFeature">
<template slot-scope="select">
<vl-style-box>
<vl-style-icon
:src="images.selectedPin"
:scale="0.5"
:anchor="[0.1, 0.5]"
:size="[128, 128]"
></vl-style-icon>
</vl-style-box>
<vl-overlay class="feature-popup" v-for="feature in select.features" :key="feature.id" :id="feature.id"
:position="pointOnSurface(feature.geometry)" :auto-pan="true" :auto-pan-animation="{ duration: 300 }">
<template slot-scope="popup">
<ResultCard :result="feature.properties.beforeNormalizedResult" :rank="feature.properties.rank" :searchAddress="feature.properties.address" :filterOptions="filterOptions"/>
</template>
</vl-overlay>
</template>
</vl-interaction-select>
<!--// interactions -->
<vl-map
:load-tiles-while-animating="true"
:load-tiles-while-interacting="true"
data-projection="EPSG:4326"

>
<vl-view :zoom.sync="zoom" :center.sync="center" :rotation.sync="rotation"></vl-view>

<vl-layer-tile id="osm">
<vl-source-osm></vl-source-osm>
</vl-layer-tile>

<vl-feature v-for="marker in markers" :properties="marker" :key="marker.id">
<div v-if="marker">
<vl-geom-point :coordinates="[Number(marker.afterNormalizedResult.lng), Number(marker.afterNormalizedResult.lat)]"></vl-geom-point>
<vl-feature v-for="marker in markers">
<vl-geom-point :coordinates="[Number(marker.lng), Number(marker.lat)]"></vl-geom-point>
<vl-style-box>
<vl-style-icon
:src="images.pin"
Expand All @@ -38,55 +21,47 @@
:size="[128, 128]"
></vl-style-icon>
</vl-style-box>
</div>
</vl-feature>

</vl-map>
</template>

<script>
import {
findPointOnSurface
} from 'vuelayers/lib/ol-ext'
import Address from './../lib/models/address';
import ResultCard from "./ResultCard";
export default {
components: {
ResultCard,
},
props: {
markers: Array,
filterOptions: Array
},
data() {
return {
center: [114.160147, 22.35201],
zoom: 11,
rotation: 0,
selectedFeature: ["position-feature"],
images: {
pin: require('../assets/pin.png'),
selectedPin: require('../assets/pin-selected.png')
}
};
},
methods: {
pointOnSurface: findPointOnSurface,
export default {
props: {
markers: {
status: Object,
geo: Array,
chi: Object,
eng: Object,
matches: Array
}
},
computed: {
center: {
get: function() {
return [114.160147, 22.35201];
},
set: function() {
// do nothing
}
},
watch: {
markers: function(newVal, oldVal) {
if (newVal[0]) {
this.center = [Number(newVal[0].afterNormalizedResult.lng), Number(newVal[0].afterNormalizedResult.lat)];
this.zoom = 16;
window.scrollTo(0, document.body.scrollHeight || document.documentElement.scrollHeight);
}
zoom: {
get: function() {
return 11;
},
set: function() {
// do nothing
}
}
};
</script>

<style>
.ol-overlay-container {
width: 100%;
},
data() {
return {
rotation: 0,
images: {
pin: require('../assets/pin.png')
}
};
}
</style>
};
</script>
Original file line number Diff line number Diff line change
Expand Up @@ -107,13 +107,7 @@ function eliminateLangKeys(data) {
const result = {};
for (const key of Object.keys(data)) {
const refinedKey = key.replace(/(^Chi|^Eng)/,'');
// eliminate with recursion
if (typeof(data[key]) === 'object') {
result[refinedKey] = eliminateLangKeys(data[key]);
} else {
result[refinedKey] = data[key];
}

result[refinedKey] = data[key];
}
return result;
}
Expand Down
Loading

0 comments on commit d62bfc3

Please sign in to comment.