Skip to content

Commit

Permalink
working on changeset error for edits w/ 2 layers in map
Browse files Browse the repository at this point in the history
ref #3196
  • Loading branch information
Jack Grossman committed May 20, 2019
1 parent 0338f19 commit 6258f33
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -693,6 +693,18 @@ public Response getTags(@Context HttpServletRequest request, @PathParam("mapId")

return Response.ok().entity(ret).build();
}

@GET
@Path("/{mapId}/startingIndex")
@Produces(MediaType.APPLICATION_JSON)
public Response getAllIds(@Context HttpServletRequest request, @PathParam("mapId") String mapId) {
Users user = Users.fromRequest(request);
Map m = getMapForRequest(request, mapId, true, false);

HashMap <String, Long> getIdsMap = m.getIdIndex();

return Response.ok().entity(getIdsMap).build();
}

/**
* Writes a map query response with no element data
Expand Down
37 changes: 37 additions & 0 deletions hoot-services/src/main/java/hoot/services/models/osm/Map.java
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@
import static hoot.services.HootProperties.MAP_QUERY_DIMENSIONS;
import static hoot.services.HootProperties.MAX_QUERY_NODES;
import static hoot.services.models.db.QCurrentNodes.currentNodes;
import static hoot.services.models.db.QCurrentWays.currentWays;
import static hoot.services.models.db.QCurrentRelations.currentRelations;
import static hoot.services.models.db.QChangesets.changesets;
import static hoot.services.models.db.QFolderMapMappings.folderMapMappings;
import static hoot.services.models.db.QFolders.folders;
import static hoot.services.models.db.QMaps.maps;
Expand All @@ -53,6 +56,7 @@

import com.querydsl.core.Tuple;
import com.querydsl.core.types.dsl.BooleanExpression;
import com.querydsl.sql.SQLQuery;

import hoot.services.geo.BoundingBox;
import hoot.services.geo.zindex.Range;
Expand Down Expand Up @@ -699,4 +703,37 @@ public boolean isVisibleTo(Users user) {
public static boolean mapExists(long id) {
return createQuery().from(QMaps.maps).where(QMaps.maps.id.eq(id)).fetchCount() > 0;
}

public HashMap<String, Long> getIdIndex() {

HashMap<String, Long> idIndex = new HashMap<String,Long>();

Long changeset = createQuery(getId())
.select(changesets.id.min())
.from(changesets)
.fetchFirst();

Long node = createQuery(getId())
.select(currentNodes.id.min())
.from(currentNodes)
.fetchFirst();

Long way = createQuery(getId())
.select(currentWays.id.min())
.from(currentWays)
.fetchFirst();

Long relation = createQuery(getId())
.select(currentRelations.id.min())
.from(currentRelations)
.fetchFirst();

idIndex.put("changeset", changeset == null || changeset >= 0 ? -1 : changeset - 1);
idIndex.put("node", node == null || node >= 0 ? -1 : node - 1);
idIndex.put("way", way == null || way >= 0 ? -1 : way - 1);
idIndex.put("relation", relation == null || relation >= 0 ? -1 : relation - 1);

return idIndex;
}

}

0 comments on commit 6258f33

Please sign in to comment.