coldfusion - 使用 Coldfusion 构建邮政编码邻近搜索
问题描述
我有一个表格,可以根据距离和邮政编码查找附近的医生。
以下是表格:
<form name="DoctorSearch" novalidate role="form">
<div style="margin-top:5px; margin-bottom:15px; text-align:center; font-size:8pt! important">
<strong>OR<br> SEARCH BY ZIP CODE RADIUS </strong>
</div>
<div style="text-align:center">
<select id="miles" name="distance">
<option disabled="disabled" selected="selected" value=""></option>
<option value="5">5</option>
<option value="10">10</option>
<option value="15">15</option>
<option value="20">20</option>
</select>
<span style="padding: 10px; border: 1px solid #ccc; border-radius: 4px; resize: vertical; margin-left: -3px; font-size: 15px;">
miles
</span>
<span style="margin-left:30px">
<input name="zip" allow-pattern="[\d\W]" id="zip" maxlength="5" placeholder="Zip code" type="text" />
</span>
</div>
<div style="margin-top:20px; margin-left:70px">
<div style="float:left">
<input onclick="return checkTextField();" type="submit" value="Search" />
</div>
<div style="float:left; margin-left:20px;">
<input type="reset" onclick="location.href = 'http://www.testsite.com';" value ="Reset" />
</div>
</div>
我能够编写一个查询,根据邮政编码查找医生(见下文)。但是,我不确定如何确定特定范围(英里/公里)内的所有内容。我怎样才能做到这一点?
<cfset name_list1 = "UICC">
<cfset name_list2 = "Medi-Cal">
<cfset name_list3 = "RMG,RCMG,RFMG">
<cfquery name="DoctorSearch" datasource="source">
SELECT Distinct officeCity, officeName, officeAddressLine1, officeState, officeZipCode, officephone, OfficeHours
FROM DocList
where utilizedspecialty in (<cfqueryparam value="#name_list1#" list="true" cfsqltype="cf_sql_varchar">)
and network not like (<cfqueryparam value="#'%name_list2%'#" list="true" cfsqltype="cf_sql_varchar">)
and Company in (<cfqueryparam value="#name_list3#" list="true" cfsqltype="cf_sql_varchar">)
and officeZipCode like '%#zip#%'
order by officeCity
</cfquery>
任何帮助,将不胜感激。
解决方案
就像上面有人说的那样,您需要一个将 zip 与 lat/lng 值相关联的表。您需要找到距离给定拉链 x 英里以内的拉链。这就是我最近的做法。下面的函数首先调用一个查询来获取提供的 zip 的 lat/lng。然后它会创建一系列 lat/lng 值,这些值在提供的 zip 的 x 英里范围内。最后,它调用一个查询,查找该 lat/lng 值范围内的所有 zip,并返回这些 zip。使用该列表,您可以找到位于该拉链范围内的医生。
public any function getZips (required string zip, required numeric miles) {
rs = searchGateway.getCoordinatesByZip(zip);
if (!rs.recordcount) {
return [zip];
}
half = (miles / 2);
maxLat = (rs.lat + (half * 0.01666));
minLat = (rs.lat - (half * 0.01666));
maxLng = (rs.lng + (half * 0.01886));
minLng = (rs.lng - (half * 0.01886));
return searchGateway.getZipsByCoordinates(maxLat, minLat, maxLng, minLng);
}
推荐阅读
- php - Moodle 事件 API
- flutter - 将数组推入列表颤动
- node.js - 在 Express POST 路由中访问 URL 查询参数
- python-3.x - 列表中的 Python 模式自动匹配
- google-cloud-platform - 如何从 GCP Cloud Build 管道内提交 GCP AI Platform 训练作业?
- c++ - 为什么我收到此错误“没有构造函数实例”,CUDA 优化器中的 viennacl 库,C++ 控制台应用程序
- python - TypeError:Decimal 类型的对象不是 JSON 可序列化的
- python - 从两个包创建最终的 Python 包
- python - 向量化矩阵计算比较关系矩阵并在 Python 中取最小值
- python - Python - 我正在尝试将以下文件复制并粘贴到我的 h 驱动器中,这是个人驱动器