Skip to content

Commit

Permalink
Supports multiple address
Browse files Browse the repository at this point in the history
  • Loading branch information
AzelyFox committed Jul 3, 2020
1 parent 8eb9cc9 commit a322d4c
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 4 deletions.
43 changes: 40 additions & 3 deletions ServerManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -52,14 +52,51 @@ public static string GeocodeResponse(HttpListenerRequest request)
if (inputId == null || inputId.Equals(String.Empty)) inputId = Constants.NAVER_SB_ID;
string inputKey = queryCollection.Get("key");
if (inputKey == null || inputKey.Equals(String.Empty)) inputKey = Constants.NAVER_SB_KEY;
string[] inputAddressArray;
string inputAddress = queryCollection.Get("address");
if (inputAddress == null || inputAddress.Equals(String.Empty)) inputAddress = "";
inputAddressArray = inputAddress.Split('|');
string inputCoordinate = queryCollection.Get("coordinate");
string requestURL = $"https://naveropenapi.apigw.ntruss.com/map-geocode/v2/geocode?query={inputAddress}&coordinate={inputCoordinate}";
if (inputCoordinate == null || inputCoordinate.Equals(String.Empty)) inputCoordinate = "";

string[] headerId;
string[] headerKey;
string[] headerAddress;
string[] headerCoordinate;
headerId = request.Headers.GetValues("id");
if (headerId != null && headerId.Length > 0)
{
inputId = headerId[0];
}
headerKey = request.Headers.GetValues("key");
if (headerKey != null && headerKey.Length > 0)
{
inputKey = headerKey[0];
}
headerAddress = request.Headers.GetValues("address");
if (headerAddress != null && headerAddress.Length > 0)
{
inputAddressArray = headerAddress;
}
headerCoordinate = request.Headers.GetValues("coordinate");
if (headerCoordinate != null && headerCoordinate.Length > 0)
{
inputCoordinate = headerCoordinate[0];
}

JArray naverGeocodeResultArray = new JArray();
WebClient naverGeocodeClient = new WebClient {Encoding = Encoding.UTF8};
naverGeocodeClient.Headers.Add("X-NCP-APIGW-API-KEY-ID", inputId);
naverGeocodeClient.Headers.Add("X-NCP-APIGW-API-KEY", inputKey);
String naverGeocodeResult = naverGeocodeClient.DownloadString(requestURL);
return naverGeocodeResult;

for (int i = 0; i < inputAddressArray.Length; i ++)
{
string requestURL = $"https://naveropenapi.apigw.ntruss.com/map-geocode/v2/geocode?query={inputAddressArray[i]}&coordinate={inputCoordinate}";
JObject resultObject = JObject.Parse(naverGeocodeClient.DownloadString(requestURL));
naverGeocodeResultArray.Add(resultObject);
}

return naverGeocodeResultArray.ToString();
}

public static string ZeroPayResponse(HttpListenerRequest request)
Expand Down
2 changes: 1 addition & 1 deletion Views/MainView.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@
</controls:HamburgerMenu>

<StatusBar Grid.Row="1">
<StatusBarItem HorizontalAlignment="Right">PAYMAP VERSION 200702A</StatusBarItem>
<StatusBarItem HorizontalAlignment="Right">PAYMAP VERSION 200704A</StatusBarItem>
</StatusBar>

</Grid>
Expand Down

0 comments on commit a322d4c

Please sign in to comment.