Tested : Move rendering rule parser to C++

This commit is contained in:
Victor Shcherb 2012-05-07 12:35:11 +02:00
parent 945c717fe9
commit a6ac11cbdb
10 changed files with 213 additions and 57 deletions

View file

@ -124,9 +124,8 @@ public class RenderingRulesStorage {
if (rule != null) {
RenderingRule toInsert = createTagValueRootWrapperRule(keys[j], rule);
toInsert.addIfElseChildren(dependsRule);
} else {
tagValueGlobalRules[i].put(keys[j], dependsRule);
}
tagValueGlobalRules[i].put(keys[j], dependsRule);
}
}
} else {
@ -443,7 +442,7 @@ public class RenderingRulesStorage {
};
storage.parseRulesFromXmlInputStream(RenderingRulesStorage.class.getResourceAsStream("test_depends.render.xml"),
resolver);
// storage.printDebug(ORDER_RULES, System.out);
storage.printDebug(TEXT_RULES, System.out);
// long tm = System.nanoTime();
// int count = 100000;
// for (int i = 0; i < count; i++) {

View file

@ -2,7 +2,7 @@
<!-- Test -->
<order>
<filter tag="highway" value="motorway" order="50" shadowLevel="1" orderType="2"/>
<filter tag="highway" value="motorway" order="50" shadowLevel="1" objectType="2"/>
<filter tag="highway" value="pedestrian" order="60" />
<filter tag="highway" value="byway" order="62" />
<filter tag="highway" value="footway" order="65" />

View file

@ -22,7 +22,7 @@
<!-- point = 1, line = 2, polygon = 3 -->
<order>
<!-- Winter: Layers -->
<group orderType="2">
<group objectType="2">
<filter tag="oa_nordic" value="" order="57" shadowLevel="1"/>
<filter tag="oa_downhill" value="" order="57" shadowLevel="1"/>
<filter tag="oa_skitour" value="" order="57" shadowLevel="1"/>

View file

@ -42,7 +42,6 @@
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/Osmand-kernel/cpufeatures_proxy}&quot;"/>
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/Osmand-kernel/jpeg/jpeg_library}&quot;"/>
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/Osmand-kernel/skia/skia_library}&quot;"/>
<listOptionValue builtIn="false" value="/home/victor/projects/android-ndk-r7c/platforms/android-3/arch-arm/usr/include"/>
</option>
<option id="gnu.cpp.compiler.option.preprocessor.def.1044210753" name="Defined symbols (-D)" superClass="gnu.cpp.compiler.option.preprocessor.def" valueType="definedSymbols">
<listOptionValue builtIn="false" value="LINUX_BUILD=true"/>
@ -50,7 +49,7 @@
<inputType id="com.android.tool.compiler.g++.input.478508689" superClass="com.android.tool.compiler.g++.input"/>
</tool>
<tool id="com.android.tool.compiler.c.1571517563" name="Android GCC" superClass="com.android.tool.compiler.c">
<option id="gnu.c.compiler.option.include.paths.741601891" name="Include paths (-I)" superClass="gnu.c.compiler.option.include.paths" valueType="includePath"/>
<option id="gnu.c.compiler.option.include.paths.741601891" name="Include paths (-I)" superClass="gnu.c.compiler.option.include.paths"/>
<inputType id="com.android.tool.compiler.c.input.1589735828" superClass="com.android.tool.compiler.c.input"/>
</tool>
<tool id="cdt.managedbuild.tool.gnu.c.linker.base.1072970274" name="GCC C Linker" superClass="cdt.managedbuild.tool.gnu.c.linker.base"/>
@ -103,10 +102,10 @@
<storageModule moduleId="org.eclipse.cdt.make.core.buildtargets"/>
<storageModule moduleId="scannerConfiguration">
<autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId=""/>
<scannerConfigBuildInfo instanceId="com.android.toolchain.gcc.128294115;com.android.toolchain.gcc.128294115.2047610242;com.android.tool.compiler.g++.592567664;com.android.tool.compiler.g++.input.893364443">
<scannerConfigBuildInfo instanceId="com.android.toolchain.gcc.128294115;com.android.toolchain.gcc.128294115.1197161253;com.android.tool.compiler.g++.1543637239.697408162;com.android.tool.compiler.g++.input.311247229">
<autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId="org.eclipse.cdt.make.core.GCCStandardMakePerFileProfile"/>
</scannerConfigBuildInfo>
<scannerConfigBuildInfo instanceId="com.android.toolchain.gcc.128294115;com.android.toolchain.gcc.128294115.1197161253;com.android.tool.compiler.g++.1543637239.697408162;com.android.tool.compiler.g++.input.311247229">
<scannerConfigBuildInfo instanceId="com.android.toolchain.gcc.128294115;com.android.toolchain.gcc.128294115.2047610242;com.android.tool.compiler.g++.592567664;com.android.tool.compiler.g++.input.893364443">
<autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId="org.eclipse.cdt.make.core.GCCStandardMakePerFileProfile"/>
</scannerConfigBuildInfo>
<scannerConfigBuildInfo instanceId="com.android.toolchain.gcc.128294115;com.android.toolchain.gcc.128294115.2018451624;com.android.tool.compiler.g++.1543637239;com.android.tool.compiler.g++.input.478508689">
@ -115,10 +114,10 @@
<scannerConfigBuildInfo instanceId="com.android.toolchain.gcc.128294115;com.android.toolchain.gcc.128294115.724578803;com.android.tool.compiler.g++.1036636492;com.android.tool.compiler.g++.input.325212280">
<autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId="org.eclipse.cdt.make.core.GCCStandardMakePerFileProfile"/>
</scannerConfigBuildInfo>
<scannerConfigBuildInfo instanceId="com.android.toolchain.gcc.128294115;com.android.toolchain.gcc.128294115.2047610242;com.android.tool.compiler.c.720867356;com.android.tool.compiler.c.input.1326523466">
<scannerConfigBuildInfo instanceId="com.android.toolchain.gcc.128294115;com.android.toolchain.gcc.128294115.1436946720;com.android.tool.compiler.c.935108432;com.android.tool.compiler.c.input.446006655">
<autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId="org.eclipse.cdt.make.core.GCCStandardMakePerFileProfile"/>
</scannerConfigBuildInfo>
<scannerConfigBuildInfo instanceId="com.android.toolchain.gcc.128294115;com.android.toolchain.gcc.128294115.1436946720;com.android.tool.compiler.c.935108432;com.android.tool.compiler.c.input.446006655">
<scannerConfigBuildInfo instanceId="com.android.toolchain.gcc.128294115;com.android.toolchain.gcc.128294115.2047610242;com.android.tool.compiler.c.720867356;com.android.tool.compiler.c.input.1326523466">
<autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId="org.eclipse.cdt.make.core.GCCStandardMakePerFileProfile"/>
</scannerConfigBuildInfo>
<scannerConfigBuildInfo instanceId="com.android.toolchain.gcc.128294115;com.android.toolchain.gcc.128294115.2018451624;com.android.tool.compiler.c.1571517563;com.android.tool.compiler.c.input.1589735828">

View file

@ -1 +1,2 @@
osmand_main
osm_out

View file

@ -40,7 +40,8 @@ jfieldID RenderingRuleSearchRequest_savedValues;
jfieldID RenderingRuleSearchRequest_savedFvalues;
RenderingRule* createRenderingRule(JNIEnv* env, jobject rRule, RenderingRulesStorage* st) {
RenderingRule* rule = new RenderingRule(map<string,string>(),st);
map<string,string> empty;
RenderingRule* rule = new RenderingRule(empty,st);
jobjectArray props = (jobjectArray) env->GetObjectField(rRule, RenderingRule_properties);
jintArray intProps = (jintArray) env->GetObjectField(rRule, RenderingRule_intProperties);
jfloatArray floatProps = (jfloatArray) env->GetObjectField(rRule, RenderingRule_floatProperties);
@ -171,10 +172,10 @@ void initRenderingRuleSearchRequest(JNIEnv* env, RenderingRuleSearchRequest* r,
jobjectArray oa = (jobjectArray) env->GetObjectField(rrs, RenderingRuleSearchRequest_props);
sz = env->GetArrayLength(oa);
std::vector<RenderingRuleProperty*> requestProps;
int* values;
float* fvalues;
int* savedValues;
float* savedFvalues;
vector<int> values;
vector<float> fvalues;
vector<int> savedValues;
vector<float> savedFvalues;
for (jsize i = 0; i < sz; i++) {
jobject prop = env->GetObjectArrayElement(oa, i);
@ -186,7 +187,7 @@ void initRenderingRuleSearchRequest(JNIEnv* env, RenderingRuleSearchRequest* r,
env->DeleteLocalRef(oa);
sz = r->storage->PROPS.properties.size();
{
values = new int[sz];
values.resize(sz , 0);
jintArray ia = (jintArray) env->GetObjectField(rrs, RenderingRuleSearchRequest_values);
jint* ie = env->GetIntArrayElements(ia, NULL);
for (int i = 0; i < sz; i++) {
@ -197,7 +198,7 @@ void initRenderingRuleSearchRequest(JNIEnv* env, RenderingRuleSearchRequest* r,
}
{
fvalues = new float[sz];
fvalues .resize(sz , 0);
jfloatArray ia = (jfloatArray) env->GetObjectField(rrs, RenderingRuleSearchRequest_fvalues);
jfloat* ie = env->GetFloatArrayElements(ia, NULL);
for (int i = 0; i < sz; i++) {
@ -208,7 +209,7 @@ void initRenderingRuleSearchRequest(JNIEnv* env, RenderingRuleSearchRequest* r,
}
{
savedValues = new int[sz];
savedValues.resize(sz , 0);
jintArray ia = (jintArray) env->GetObjectField(rrs, RenderingRuleSearchRequest_values);
jint* ie = env->GetIntArrayElements(ia, NULL);
for (int i = 0; i < sz; i++) {
@ -219,7 +220,7 @@ void initRenderingRuleSearchRequest(JNIEnv* env, RenderingRuleSearchRequest* r,
}
{
savedFvalues = new float[sz];
savedFvalues .resize(sz , 0);
jfloatArray ia = (jfloatArray) env->GetObjectField(rrs, RenderingRuleSearchRequest_fvalues);
jfloat* ie = env->GetFloatArrayElements(ia, NULL);
for (int i = 0; i < sz; i++) {

View file

@ -14,6 +14,8 @@ void osmand_log_print(int type, const char* msg, ...) {
__android_log_print(ANDROID_LOG_ERROR, LOG_TAG, msg, args);
} else if(type == LOG_INFO) {
__android_log_print(ANDROID_LOG_INFO, LOG_TAG, msg, args);
} else if(type == LOG_WARN) {
__android_log_print(ANDROID_LOG_WARN, LOG_TAG, msg, args);
} else {
__android_log_print(ANDROID_LOG_DEBUG, LOG_TAG, msg, args);
}
@ -28,8 +30,17 @@ const char* const LOG_TAG = "net.osmand:native";
void osmand_log_print(int type, const char* msg, ...) {
va_list args;
va_start( args, msg);
// TODO by type
printf(msg, args);
if(type == LOG_ERROR) {
printf("ERROR: ");
} else if(type == LOG_INFO) {
printf("INFO: ");
} else if(type == LOG_WARN) {
printf("WARN: ");
} else {
printf("DEBUG: ");
}
vprintf(msg, args);
printf("\n");
va_end(args);
}

View file

@ -1,4 +1,5 @@
#include "binaryRead.h"
#include "renderRules.h"
#include "rendering.h"
#include <SkImageEncoder.h>
#include <stdio.h>
@ -219,8 +220,48 @@ void runSimpleRendering(const char* fileName, RenderingInfo* info) {
return;
}
class BasePathRenderingRulesStorageResolver : public RenderingRulesStorageResolver {
public:
string path;
BasePathRenderingRulesStorageResolver(string path) : path(path) {
}
virtual RenderingRulesStorage* resolve(string name, RenderingRulesStorageResolver* ref) {
string file = path;
file += name;
file+=".render.xml";
RenderingRulesStorage* st = new RenderingRulesStorage(file.c_str());
st->parseRulesFromXmlInputStream(file.c_str(), this);
return st;
}
virtual ~BasePathRenderingRulesStorageResolver() {}
};
void testRenderingRuleStorage(const char* basePath, const char* name) {
string filePath = string(basePath) + string(name);
RenderingRulesStorage* st = new RenderingRulesStorage(filePath.c_str());
st->parseRulesFromXmlInputStream(filePath.c_str(),
new BasePathRenderingRulesStorageResolver(string(basePath)));
st->printDebug(RenderingRulesStorage::TEXT_RULES);
RenderingRuleSearchRequest* searchRequest = new RenderingRuleSearchRequest(st);
searchRequest->setStringFilter(st->PROPS.R_TAG, "highway");
searchRequest->setStringFilter(st->PROPS.R_VALUE, "motorway");
searchRequest->setIntFilter(st->PROPS.R_LAYER, 1);
searchRequest->setIntFilter(st->PROPS.R_MINZOOM, 15);
searchRequest->setIntFilter(st->PROPS.R_MAXZOOM, 15);
// searchRequest.setBooleanFilter(storage.PROPS.R_NIGHT_MODE, true);
// searchRequest.setBooleanFilter(storage.PROPS.get("hmRendered"), true);
bool res = searchRequest->search(RenderingRulesStorage::LINE_RULES, true);
printf("Result %d\n", res);
searchRequest->printDebugResult();
}
int main(int argc, char **argv) {
if (argc <= 1) {
// testRenderingRuleStorage("/home/victor/projects/OsmAnd/git/DataExtractionOSM/src/net/osmand/render/",
// "test_depends.render.xml"
// "default.render.xml"
// );
printUsage("");
return 1;
}

View file

@ -22,7 +22,7 @@ int parseColor(string colorString) {
if (colorString[0] == '#') {
// Use a long to avoid rollovers on #ffXXXXXX
char** end;
long color = strtol(colorString.c_str() + 1, end , 16);
long color = strtol(colorString.c_str() + 1, NULL, 16);
if (colorString.size() == 7) {
// Set the alpha value
color |= 0x00000000ff000000;
@ -36,24 +36,28 @@ int parseColor(string colorString) {
}
string colorToString(int color) {
string s;
osmand_log_print(LOG_ERROR, "FIXME color to string %hd", color);
return s;
char c[9];
if ((0xFF000000 & color) == 0xFF000000) {
sprintf(c, "%x", (color & 0x00FFFFFF));
} else {
sprintf(c, "%x", color);
}
return string(c);
}
RenderingRule::RenderingRule(map<string, string> attrs, RenderingRulesStorage* storage) {
RenderingRule::RenderingRule(map<string, string>& attrs, RenderingRulesStorage* storage) {
properties.reserve(attrs.size());
intProperties.assign(attrs.size(), -1);
map<string, string>::iterator it = attrs.begin();
int i = 0;
for (; it != attrs.end(); it++) {
HMAP::hash_map<std::string, RenderingRuleProperty*>::iterator find = storage->PROPS.properties.find(it->first);
if (find == storage->PROPS.properties.end()) {
RenderingRuleProperty* property = storage->PROPS.getProperty(it->first.c_str());
if (property == NULL) {
printf("Property %s was not found in registry", it->first.c_str());
osmand_log_print(LOG_ERROR, "Property %s was not found in registry", it->first.c_str());
return ;
}
i++;
RenderingRuleProperty* property = find->second;
properties.push_back(property);
if (property->isString()) {
@ -67,6 +71,7 @@ RenderingRule::RenderingRule(map<string, string> attrs, RenderingRulesStorage* s
} else {
intProperties[i] = property->parseIntValue(it->second);
}
i++;
}
}
@ -197,8 +202,9 @@ class RenderingRulesHandler {
}
static map<string, string>& parseAttributes(const char **atts, map<string, string>& m) {
while (atts != 0) {
m[string(*(atts++))] = string(*(atts++));
while (*atts != NULL) {
m[string(atts[0])] = string(atts[1]);
atts += 2;
}
return m;
}
@ -221,8 +227,10 @@ class RenderingRulesHandler {
t->st.top().singleRule->ifElseChildren.push_back(renderingRule);
} else {
t->storage->registerGlobalRule(renderingRule, t->state);
}
t->st.push(GroupRules(renderingRule));
GroupRules gr(renderingRule);
t->st.push(gr);
} else if ("groupFilter" == name) { //$NON-NLS-1$
map<string, string> attrsMap;
parseAttributes(atts, attrsMap);
@ -240,7 +248,6 @@ class RenderingRulesHandler {
GroupRules groupRules;
if (t->st.size() > 0 && t->st.top().isGroup()) {
groupRules.groupAttributes.insert(t->st.top().groupAttributes.begin(), t->st.top().groupAttributes.end());
t->st.top().childrenGroups.push_back(groupRules);
}
parseAttributes(atts, groupRules.groupAttributes);
t->st.push(groupRules);
@ -258,7 +265,8 @@ class RenderingRulesHandler {
map<string, string> attrsMap;
parseAttributes(atts, attrsMap);
string attr = attrsMap["name"];
RenderingRule* root = new RenderingRule(map<string, string>(),t->storage);
map<string, string> empty;
RenderingRule* root = new RenderingRule(empty,t->storage);
t->storage->renderingAttributes[name] = root;
t->st.push(GroupRules(root));
} else if ("renderingProperty" == name) {
@ -319,6 +327,8 @@ class RenderingRulesHandler {
t->st.pop();
if (t->st.size() == 0) {
group.registerGlobalRules(t->storage,t->state);
} else if(t->st.top().isGroup()){
t->st.top().childrenGroups.push_back(group);
}
} else if ("groupFilter" == name) { //$NON-NLS-1$
t->st.pop();
@ -329,6 +339,36 @@ class RenderingRulesHandler {
};
void RenderingRule::printDebugRenderingRule(string indent, RenderingRulesStorage * st) {
indent += " ";
printf("\n%s", indent.c_str());
vector<RenderingRuleProperty*>::iterator pp = properties.begin();
for (; pp != properties.end(); pp++) {
printf(" %s=", (*pp)->attrName.c_str());
if ((*pp)->isString()) {
printf("\"%s\"", getStringPropertyValue((*pp)->attrName, st).c_str());
} else if ((*pp)->isFloat()) {
printf("%f", getFloatPropertyValue((*pp)->attrName));
} else if ((*pp)->isColor()) {
printf("%s", getColorPropertyValue((*pp)->attrName).c_str());
} else if ((*pp)->isIntParse()) {
printf("%d", getIntPropertyValue((*pp)->attrName));
}
}
vector<RenderingRule*>::iterator it = ifElseChildren.begin();
for (; it != ifElseChildren.end(); it++) {
(*it)->printDebugRenderingRule(indent, st);
}
}
void RenderingRulesStorage::printDebug(int state) {
HMAP::hash_map<int, RenderingRule*>::iterator it = tagValueGlobalRules[state].begin();
for (; it != tagValueGlobalRules[state].end(); it++) {
printf("\n\n%s : %s", getTagString(it->first).c_str(), getValueString(it->first).c_str());
it->second->printDebugRenderingRule(string(""), this);
}
}
void RenderingRulesStorage::parseRulesFromXmlInputStream(const char* filename, RenderingRulesStorageResolver* resolver) {
XML_Parser parser = XML_ParserCreate(NULL);
RenderingRulesHandler* handler = new RenderingRulesHandler(resolver, this);
@ -336,6 +376,7 @@ void RenderingRulesStorage::parseRulesFromXmlInputStream(const char* filename, R
XML_SetElementHandler(parser, RenderingRulesHandler::startElementHandler, RenderingRulesHandler::endElementHandler);
FILE *file = fopen(filename, "r");
if (file == NULL) {
osmand_log_print(LOG_ERROR, "File can not be open %s", filename);
return;
}
char buffer[512];
@ -373,7 +414,7 @@ void RenderingRulesStorage::parseRulesFromXmlInputStream(const char* filename, R
continue;
}
HMAP::hash_map<int, RenderingRule*>::iterator it = depends->tagValueGlobalRules[i].begin();
for (; it != depends->tagValueGlobalRules[i].begin(); it++) {
for (; it != depends->tagValueGlobalRules[i].end(); it++) {
HMAP::hash_map<int, RenderingRule*>::iterator o = tagValueGlobalRules[i].find(it->first);
RenderingRule* toInsert = it->second;
if (o != tagValueGlobalRules[i].end()) {
@ -390,16 +431,24 @@ void RenderingRulesStorage::parseRulesFromXmlInputStream(const char* filename, R
RenderingRuleSearchRequest::RenderingRuleSearchRequest(RenderingRulesStorage* storage) {
this->storage = storage;
PROPS = &this->storage->PROPS;
clearState();
PROPS = &(this->storage->PROPS);
this->values.resize(PROPS->properties.size(), 0);
this->fvalues.resize(PROPS->properties.size(), 0);
HMAP::hash_map<string, RenderingRuleProperty*>::iterator it = PROPS->properties.begin();
for (; it != PROPS->properties.end(); it++) {
if (!it->second->isColor()) {
values[it->second->id] = -1;
}
}
saveState();
}
void RenderingRuleSearchRequest::saveState() {
this->savedFvalues = fvalues;
this->savedValues = values;
}
RenderingRuleSearchRequest::~RenderingRuleSearchRequest() {
delete PROPS;
delete[] fvalues;
delete[] values;
delete[] savedFvalues;
delete[] savedValues;
}
int RenderingRuleSearchRequest::getIntPropertyValue(RenderingRuleProperty* prop) {
@ -444,11 +493,11 @@ void RenderingRuleSearchRequest::setIntFilter(RenderingRuleProperty* p, int filt
}
}
void RenderingRuleSearchRequest::externalInitialize(int* vs, float* fvs, int* sVs, float* sFvs){
void RenderingRuleSearchRequest::externalInitialize(vector<int>& vs, vector<float>& fvs, vector<int>& sVs, vector<float>& sFvs){
this->values = vs;
this->fvalues = fvs;
this->savedFvalues = sFvs;
this->savedValues = sVs;
this->savedFvalues = sFvs;
}
void RenderingRuleSearchRequest::clearIntvalue(RenderingRuleProperty* p) {
@ -568,8 +617,8 @@ bool RenderingRuleSearchRequest::visitRule(RenderingRule* rule, bool loadOutput)
void RenderingRuleSearchRequest::clearState() {
obj = NULL;
memcpy(values, savedValues, storage->PROPS.properties.size() * sizeof(int));
memcpy(fvalues, savedFvalues, storage->PROPS.properties.size() * sizeof(float));
values = savedValues;
fvalues = savedFvalues;
}
void RenderingRuleSearchRequest::setInitialTagValueZoom(std::string tag, std::string value, int zoom, MapDataObject* obj) {
@ -590,5 +639,44 @@ void RenderingRuleSearchRequest::setTagValueZoomLayer(std::string tag, std::stri
setStringFilter(PROPS->R_VALUE, val);
}
bool RenderingRuleSearchRequest::isSpecified(RenderingRuleProperty* p) {
if (p->isFloat()) {
return fvalues[p->id] != 0;
} else {
int val = values[p->id];
if (p->isColor()) {
return val != 0;
} else {
return val != -1;
}
}
}
void RenderingRuleSearchRequest::printDebugResult() {
if (searchResult) {
printf("\n Found : ");
HMAP::hash_map<string, RenderingRuleProperty*>::iterator it = PROPS->properties.begin();
for (; it != PROPS->properties.end(); ++it) {
RenderingRuleProperty* rp = it->second;
if (!rp->input && isSpecified(rp)) {
printf(" %s=", rp->attrName.c_str());
if (rp->isString()) {
printf("\"%s\"", getStringPropertyValue(rp).c_str());
} else if (rp->isFloat()) {
printf("%f", getFloatPropertyValue(rp));
} else if (rp->isColor()) {
printf("%s", colorToString(getIntPropertyValue(rp)).c_str());
} else if (rp->isIntParse()) {
printf("%d", getIntPropertyValue(rp));
}
}
}
printf("\n");
} else {
printf("\nNot found\n");
}
}
#endif

View file

@ -139,7 +139,8 @@ public:
std::vector<RenderingRule*> ifElseChildren;
std::vector<RenderingRule*> ifChildren;
RenderingRule (map<string, string> attrs, RenderingRulesStorage* storage);
RenderingRule(map<string, string>& attrs, RenderingRulesStorage* storage);
void printDebugRenderingRule(string indent, RenderingRulesStorage * st);
private :
inline int getPropertyIndex(string property) {
for (int i = 0; i < properties.size(); i++) {
@ -168,7 +169,7 @@ class RenderingRulesStorageResolver {
public:
virtual RenderingRulesStorage* resolve(string name, RenderingRulesStorageResolver* ref) = 0;
virtual ~RenderingRulesStorageResolver();
virtual ~RenderingRulesStorageResolver() {}
};
@ -364,16 +365,17 @@ public:
const static int POLYGON_RULES = 3;
const static int TEXT_RULES = 4;
const static int ORDER_RULES = 5;
RenderingRulesStorage(void* storage, bool createDefProperties = true) : storageId(storage),
RenderingRulesStorage(const void* storage, bool createDefProperties = true) : storageId(storage),
PROPS(createDefProperties) {
tagValueGlobalRules = new HMAP::hash_map<int, RenderingRule*>[SIZE_STATES];
getDictionaryValue("");
}
~RenderingRulesStorage() {
delete[] tagValueGlobalRules;
// proper
}
void* storageId;
const void* storageId;
RenderingRule* getRule(int state, int itag, int ivalue);
@ -394,7 +396,11 @@ public:
}
inline int getDictionaryValue(std::string s) {
return dictionaryMap[s];
HMAP::hash_map<std::string, int>::iterator it = dictionaryMap.find(s);
if(it == dictionaryMap.end()) {
return registerString(s);
}
return it->second;
}
void parseRulesFromXmlInputStream(const char* filename, RenderingRulesStorageResolver* resolver);
@ -403,6 +409,8 @@ public:
return dictionary[i];
}
void printDebug(int state);
private:
RenderingRule* createTagValueRootWrapperRule(int tagValueKey, RenderingRule* previous);
@ -427,10 +435,10 @@ class RenderingRuleSearchRequest
{
private :
RenderingRulesStorageProperties* PROPS;
int* values;
float* fvalues;
int* savedValues;
float* savedFvalues;
vector<int> values;
vector<float> fvalues;
vector<int> savedValues;
vector<float> savedFvalues;
bool searchResult;
MapDataObject* obj;
@ -467,12 +475,20 @@ public:
void clearState();
void saveState();
void setInitialTagValueZoom(std::string tag, std::string value, int zoom, MapDataObject* obj);
void setTagValueZoomLayer(std::string tag, std::string val, int zoom, int layer, MapDataObject* obj);
void externalInitialize(int* values, float* fvalues, int* savedValues, float* savedFvalues);
void printDebugResult();
void externalInitialize(vector<int>& vs, vector<float>& fvs, vector<int>& sVs, vector<float>& sFvs);
bool isSpecified(RenderingRuleProperty* p);
};