Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactored by concatenating String to be appended to StringBuilder #68

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -181,18 +181,14 @@ public void setLabel(String label) {
@Override
public String toString() {
StringBuilder builder = new StringBuilder();
builder.append("GisgraphySearchEntry [featureId=");
builder.append(featureId);
builder.append(", ");
String stringfeatureId = "GisgraphySearchEntry [featureId="+featureId+", ";
builder.append(stringfeatureId);
if (name != null) {
builder.append("name=");
builder.append(name);
builder.append(", ");
String strName = "name=" + name + ", ";
builder.append(strName);
}
if (isIn != null) {
builder.append("isIn=");
builder.append(isIn);
builder.append(", ");
builder.append("isIn="+isIn+", ");
}
builder.append("]");
return builder.toString();
Expand Down
19 changes: 6 additions & 13 deletions src/main/java/com/graphhopper/converter/core/Converter.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,11 @@
public class Converter {

public static GHEntry convertFromNetToolKitAddress(NetToolKitAddressEntry ntkEntry) {
GHEntry rsp = new GHEntry(null, null, ntkEntry.getLat(),
return new GHEntry(null, null, ntkEntry.getLat(),
ntkEntry.getLng(), ntkEntry.getAddress(), null, null,
ntkEntry.getCountry(), null, ntkEntry.getCity(),
ntkEntry.getState(), null, ntkEntry.getCounty(), ntkEntry.getStreet(),
ntkEntry.getHouseNumber(), ntkEntry.getPostalCode(), null);
return rsp;
}

public static Response convertFromNetToolKitList(
Expand All @@ -40,21 +39,19 @@ public static Response convertFromNetToolKitList(
}

public static GHEntry convertFromGisgraphyAddress(GisgraphyAddressEntry gisgraphyEntry) {
GHEntry rsp = new GHEntry(null, null, gisgraphyEntry.getLat(),
return new GHEntry(null, null, gisgraphyEntry.getLat(),
gisgraphyEntry.getLng(), gisgraphyEntry.getDisplayName(), null, null,
gisgraphyEntry.getCountry(), null, gisgraphyEntry.getCity(),
gisgraphyEntry.getState(), null, null, gisgraphyEntry.getStreetName(),
gisgraphyEntry.getHouseNumber(), gisgraphyEntry.getZipCode(), null);
return rsp;
}

public static GHEntry convertFromGisgraphySearch(GisgraphySearchEntry gisgraphyEntry) {
GHEntry rsp = new GHEntry(null, null, gisgraphyEntry.getLat(),
return new GHEntry(null, null, gisgraphyEntry.getLat(),
gisgraphyEntry.getLng(), gisgraphyEntry.getLabel(), null, null,
gisgraphyEntry.getCountry(), null, gisgraphyEntry.getIsIn(),
gisgraphyEntry.getAdm1Name(), null, null, gisgraphyEntry.getName(),
gisgraphyEntry.getHouseNumber(), gisgraphyEntry.getZipCode(), null);
return rsp;
}

public static Response convertFromGisgraphyList(
Expand Down Expand Up @@ -98,9 +95,8 @@ public static Response convertFromGisgraphySearchList(
}

public static GHEntry convertFromNominatim(NominatimEntry response) {
GHEntry rsp = new GHEntry(response.getOsmId(), response.getGHOsmType(), response.getLat(), response.getLon(),
return new GHEntry(response.getOsmId(), response.getGHOsmType(), response.getLat(), response.getLon(),
response.getDisplayName(), null, response.getType(), response.getAddress(), response.getExtent());
return rsp;
}

public static Response convertFromNominatimList(List<NominatimEntry> nominatimResponses, Status status, String locale) {
Expand Down Expand Up @@ -153,10 +149,8 @@ public static GHEntry convertFromOpenCageData(OpenCageDataEntry response) {
}
}

GHEntry rsp = new GHEntry(osmId, type, response.getGeometry().lat, response.getGeometry().lng,
return new GHEntry(osmId, type, response.getGeometry().lat, response.getGeometry().lng,
response.getFormatted(), null, response.getComponents().type, response.getComponents(), response.getExtent());

return rsp;
}

public static Response convertFromOpenCageData(OpenCageDataResponse ocdRsp, Status status, String locale) {
Expand All @@ -176,12 +170,11 @@ public static Response convertFromOpenCageData(OpenCageDataResponse ocdRsp, Stat
}

public static GHEntry convertFromPelias(PeliasEntry response) {
GHEntry rsp = new GHEntry(response.properties.getOsmId(), response.properties.getGHOsmType(),
return new GHEntry(response.properties.getOsmId(), response.properties.getGHOsmType(),
response.geometry.getLat(), response.geometry.getLon(), response.properties.name, null, null,
response.properties.country, null, response.properties.locality, response.properties.region,
response.properties.macrocounty, response.properties.county, response.properties.street,
response.properties.housenumber, response.properties.postalcode, response.getExtent());
return rsp;
}

public static Response convertFromPelias(PeliasResponse peliasRsp, Status status, String locale) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,7 @@ abstract class AbstractConverterResource {
protected final Logger LOGGER = LoggerFactory.getLogger(this.getClass());

int fixLimit(int limit) {
if (limit > 10) {
return 10;
}
return limit;
return Math.min(limit, 10);
}

void checkInvalidParameter(boolean reverse, String query, String point) {
Expand Down