private GeocodeConstraints BuildConstraints() { GeocodeConstraints result = new GeocodeConstraints(); result.CloseMatchesOnly = cbCloseMatchesOnly.Checked; result.FallbackToPostal = cbFallbackPostal.Checked; result.FallbackToGeographic = cbFallbackGeographic.Checked; result.MustMatchAddressNumber = cbMatchAddrNumber.Checked; result.MustMatchMainAddress = cbMatchMainAddr.Checked; result.MustMatchInput = cbMatchInput.Checked; result.MustMatchMunicipality = cbMatchCity.Checked; result.MustMatchCountrySubdivision = cbMatchState.Checked; result.MustMatchPostalCode = cbMatchPostal.Checked; result.MustMatchCountry = cbMatchCountry.Checked; result.MaxCandidates = (int) maxCandidates.Value; result.MaxRanges = (int) maxRanges.Value; result.MaxRangeUnits = (int) maxRangeUnits.Value; System.Globalization.CultureInfo culture = new System.Globalization.CultureInfo("en-US"); MapInfo.Geometry.Distance offset = new MapInfo.Geometry.Distance(25.0, MapInfo.Geometry.DistanceUnit.Foot); offset.Value = Convert.ToDouble(streetOffset.Text, culture); offset.Unit = MapInfo.Geometry.CoordSys.DistanceUnitFromKeyword(streetOffsetUnits.Text); result.OffsetFromStreet = offset; offset.Value = Convert.ToDouble(cornerOffset.Text, culture); offset.Unit = MapInfo.Geometry.CoordSys.DistanceUnitFromKeyword(cornerOffsetUnits.Text); result.OffsetFromCorner = offset; result.GeocodeType = (MapInfo.Geocoding.GeocodeType) Enum.Parse(typeof(MapInfo.Geocoding.GeocodeType), geocodeType.Text); result.DictionaryUsage = (MapInfo.Geocoding.DictionaryUsage) Enum.Parse(typeof(MapInfo.Geocoding.DictionaryUsage), dictionaryUsage.Text); return result; }
private void SetDefaultConstraints() { GeocodeConstraints constraints; try { constraints = _geocodeClient.DefaultGeocodeConstraints; } catch (GeocodingException ex) { constraints = new GeocodeConstraints(); } cbCloseMatchesOnly.Checked = constraints.CloseMatchesOnly; cbFallbackPostal.Checked = constraints.FallbackToPostal; cbFallbackGeographic.Checked= constraints.FallbackToGeographic; cbMatchAddrNumber.Checked = constraints.MustMatchAddressNumber; cbMatchMainAddr.Checked = constraints.MustMatchMainAddress; cbMatchInput.Checked = constraints.MustMatchInput; cbMatchCity.Checked = constraints.MustMatchMunicipality; cbMatchState.Checked = constraints.MustMatchCountrySubdivision; cbMatchPostal.Checked = constraints.MustMatchPostalCode; cbMatchCountry.Checked = constraints.MustMatchCountry; maxCandidates.Value = constraints.MaxCandidates; maxRanges.Value = constraints.MaxRanges; maxRangeUnits.Value = constraints.MaxRangeUnits; streetOffset.Text = constraints.OffsetFromStreet.Value.ToString(); streetOffsetUnits.Text = MapInfo.Geometry.CoordSys.DistanceUnitKeyword(constraints.OffsetFromStreet.Unit); cornerOffset.Text = constraints.OffsetFromCorner.Value.ToString(); cornerOffsetUnits.Text = MapInfo.Geometry.CoordSys.DistanceUnitKeyword(constraints.OffsetFromCorner.Unit); geocodeType.Text = constraints.GeocodeType.ToString(); dictionaryUsage.Text = constraints.DictionaryUsage.ToString(); }